Skip to main content

Full text of "Selected Papers on Fun & Games"

See other formats


mm 

mm 

mm 

mm 

mm 

mm 

mm 




SeleBed Papers on “Tun & Qames 


OCT 2011 






CSLI Lecture Notes Number 192 

(Q 


Selected 

« 


‘Tapers on 



‘Tun & 



Qames 



fa 

« 


Donald E. Knuth 


£QP$; 

T CSLI Publications 

V Stanford. California 


P&gQ; 


-Q 

£^5 ep^ (p^5 <p^ 







‘TJjjX’ is a trademark of the American Mathematical Society. 

‘METflFONT’ is a trademark of Addison- Wesley. 

‘On-Line Encyclopedia of Integer Sequences’ and ‘OEIS’ are trademarks of 
the OEIS Foundation Inc. 


Copyright ©2011 

Center for the Study of Language and Information 
Leland Stanford Junior University 
17 16 15 14 13 12 11 5 4 3 2 1 


Library of Congress Cataloging-in-Publication Data 

Knuth, Donald Ervin, 1938- 

Selected papers on fun and games / Donald E. Knuth. 
xvii,741 p. 23 cm. — (CSLI lecture notes ; no. 192) 

Includes bibliographical references and index. 

ISBN 978-1-57586-585-0 (cloth : alk. paper) — 

ISBN 978-1-57586-584-3 (pbk. : alk. paper) 

1. Mathematics — Miscellanea. 2. Computer science — Miscellanea. 
I. Title. II. Series. 

QA99.K58 2010 

510— dc22 2010032404 

CIP 


Internet page 

http : //www-cs-f acuity . stanford.edu/~knuth/fg.html 
contains further information and links to related books. 



to Martin Gardner (1914-2010) 
who inspired most of these words 



Contents 


1 The Potrzebie System of Weights and Measures 1 

2 Official Tables of the Potrzebie System 9 

3 The Revolutionary Potrzebie 19 

4 A MAD Crossword 27 

5 Counterexample to a Statement of Peano 31 

6 The Complexity of Songs 33 

7 TPK in INTERCAL 41 

8 Math Ace: The Plot Thickens 59 

9 Billiard Balls in an Equilateral Triangle 63 

10 Representing Numbers Using Only One 4 69 

11 Very Magic Squares 73 

12 The Gamow-Stern Elevator Problem 79 

13 Fibonacci Multiplication 87 

14 A Fibonacci-Like Sequence of Composite Numbers 93 

15 Transcendental Numbers Based on the Fibonacci Sequence 99 

16 Supernatural Numbers 103 

17 Mathematical Vanity Plates 121 

18 Diamond Signs 161 

19 The Orchestra Song 179 

20 Gnebbishland 185 

21 A Carol for Advent 189 

22 Randomness in Music 193 

23 Basketball’s Electronic Coach 199 

24 The Triel: A New Solution 209 

25 The Computer as Master Mind 219 

26 Move It Or Lose It 231 

27 Adventure 235 

vii 


viii Selected Papers on Fun and Games 

28 Ziegler’s Giant Bar 395 

29 T1i 5 E 4 CH 3 EmIC 2 Al 2 Ca 3 P 4 Er 401 

30 N-Ciphered Texts 405 

31 Disappearances 411 

32 Lewis Carroll’s word ward ware-dare -dame-game 415 

33 Blood, Sweat, and Tears 421 

34 Biblical Ladders 423 

35 ETAOIN SHRDLU Non-Crashing Sets 429 

36 Quadrata Obscura (Hidden Latin Squares) 431 

37 5 x5 x 5 Word Cubes by Computer 433 

38 Dancing Links 437 

39 Nikoli Puzzle Favors 473 

40 Uncrossed Knight’s Tours 477 

41 Celtic Knight’s Tours 489 

42 Long and Skinny Knight’s Tours 511 

43 Leaper Graphs 541 

44 Number Representations and Dragon Curves 571 

45 Mathematics and Art: The Dragon Curve in Ceramic Tile 615 

46 Christmas Cards 623 

47 Geek Art 657 

48 Memories of Martin Gardner 705 

49 An Earthshaking Announcement 707 
Index 717 


Preface 


Mathematics and computer science can be both playful and serious 
at the same time. That’s why research in those fields is so much fun. But 
recreational aspects are often played down, because of a popular notion 
that the pursuit of pleasure is somehow just a minor goal, of little 
importance. College professors like me are mainly expected to keep our 
noses to the grindstone so that we produce works of “real value.” 

This book takes the opposite approach. It brings together dozens 
of things that I’ve written during the past 50-plus years in which the 
primary focus has simply been to enjoy the ride and to develop new 
patterns that add to life’s pleasures. 

Maybe I’m just a cockeyed optimist. I do know that life is full of 
significant challenges, that billions of people are forced to lead a hard- 
scrabble existence, and that, hey, “All work and no play makes jack.” 
But for me, the pursuit of money has always played second fiddle to 
the pursuit of beauty. Thank goodness for mathematics and computer 
science, whose methods offer many ways by which our left brains and 
our right brains can both be happy, simultaneously. 

I’m dedicating this book to Martin Gardner, the grand master of 
mathematical recreations, who has inspired much of what appears inside. 
He gave a nice characterization of the subject matter in his book A 
Gardner’s Workout [Natick, Massachusetts: A K Peters, 2001, page 192]: 

Obviously no sharp line separates entertaining math from seri- 
ous math. One reason is that creative mathematicians regard 
their work as much a form of play as golf is to a professional 
golfer. In general, math is considered recreational if it has a 
strong aspect of play that can be appreciated by any layman 
interested in mathematics. 

Indeed, I’ve never been able to see any boundary between scientific re- 
search and game-playing. Over the years, I’ve used many of the topics 
in this book as the basis for entertaining and instructive talks given to 


IX 


x Selected Papers on Fun and Games 

advanced high-school students or to undergraduate math clubs, and the 
audiences were enthusiastic about the ideas. 

The topics treated here were often inspired by patterns that are visu- 
ally compelling, or by paradoxical truths that are logically compelling, 
or by combinations of numbers and/or symbols that fit together just 
right. These were papers that I couldn’t not write. 

I believe that the creation of a great puzzle or a great pattern is 
a scholarly achievement of great merit, an important contribution to 
world culture, even though the author of such a breakthrough is often 
an amateur who has no academic credentials. Therefore I’ve devoted 
considerable time to tracing the history of the often unsung pioneers 
who have come up with significant new “mind-benders” as civilization 
developed, and I’m proud to follow in their footsteps. 

Many years ago I wrote an essay that asked “Are toy problems use- 
ful?” [reprinted as Chapter 10 in Selected Papers on Computer Science] 
in which I discussed at some length my view that students are best served 
by teachers who present them with well-chosen recreational problems. 
And I’ve carried on in the same vein ever since, most recently on pages 
7-9 of The Art of Computer Programming, Volume 4A, in a subsection 
entitled “Puzzles versus the real world.” 

Thus it’s not surprising that many of the chapters in the present 
book have resulted from my attempts to answer puzzling questions that 
have no immediately obvious relation to any practical applications of 
mathematics or of computer science. Or that sometimes I had an urge to 
embellish or extend the answers to classical enigmas that had previously 
been resolved. And of course I’ve also come up with a few new puzzles 
in the process, several of which I don’t yet know how to tackle. 

In other words, I believe that diversions are useful, and I’ve tried 
in this book to provide useful diversions that meet high standards of 
quality. Of all the papers that I’ve written, the ones included here have 
given me the most personal pleasure — in fact, sheer joy at times! The 
various chapters include my earliest work as well as my latest. Many of 
them have an autobiographical flavor, because they’re associated with 
some of the most memorable moments of my life. 

Actually I’ve had great fun with these papers not only when writing 
them but also when revisiting them, as I was preparing this collection. 
Now, as I write this preface, I can’t help but celebrate the fact that I’ve 
finally been able to put together the book that I’ve always dreamed of 
writing, a book that best expresses the quirky things that I enjoy. I’m 
quite sure that this book isn’t for everybody; but if you’re anything like 
me, you will enjoy it too, at least in part. 


Preface xi 


Chapter 1 reprints the article that has always headed my list of tech- 
nical publications, in spite of the fact that it did not appear in a scientific 
journal. One has to start somewhere, and for me the natural starting 
place was MAD magazine. Chapter 2 presents the (much longer) origi- 
nal manuscript from which the MAD editors selected a digestible subset. 
And Chapter 3 is my own attempt at boiling down the details, in this 
case for the engineering magazine that had just been launched at my un- 
dergraduate college. These three chapters contain everything that you’ll 
ever want to know, and more, about the Potrzebie System of Weights 
and Measures. Then, to round out the story, Chapter 4 presents my 
first rejected paper: MAD didn’t want this one. 

Now let’s fast forward a few years. Chapter 5 is a short spoof of a 
formal math paper, privately circulated when my wife and I announced 
the birth of our son John in 1965. That served as a model for the more 
elaborate spoof in Chapter 6, “The complexity of songs,” inspired by a 
road trip with 11-year-old John and his 9-year-old sister Jenny. 

Chapter 7 is zany in yet a different way. Science and mathematics 
are fun, but so is programming; this chapter completes my earlier study 
of the world’s first 20 programming languages by discussing the world’s 
canonically worst programming language. There’s hacker hilarity here, if 
you’re ready for it; people who are sufficiently weird may enjoy decoding 
some of the purest ultrarefined geekology that Pve ever come up with. 

Recreational mathematics comes next. Chapter 8 contains two short 
notes about graph plotting that I wrote as an undergraduate; then Chap- 
ter 9 discusses a problem about billiard balls that launched my many 
years of correspondence with Martin Gardner. In Chapter 10 I explore 
what can happen if we start with the number 4 and repeatedly take fac- 
torials and/or square roots. Square arrays of numbers that are “magic” 
in almost all conceivable directions are investigated in Chapter 11. Then 
Chapter 12 deals with a probability paradox, related to elevators that 
move at random. 

Fibonacci numbers, which are capable of endless surprises, now come 
into play. Chapter 13 uses them to define a new kind of multiplication 
with noteworthy properties; Chapter 14 uses them to construct a re- 
markable linear recurrence of integers that includes no prime numbers; 
and Chapter 15 uses them to define fundamental constants that satisfy 
no polynomial equation with integer coefficients. 

Some readers who get to page 100 might ask, “Are we having fun 
yet?” Well, surely Fibonacci numbers are fun. But perhaps even more so 
are the huge, “supernatural” numbers considered in Chapter 16, which 
features a guessing game that is equivalent to efficient coding schemes. 


xii Selected Papers on Fun and Games 

Then comes a change of pace and a change of place, from my desk 
to my automobile: Chapters 17 and 18 are devoted to curious things 
that have caught my attention during a lifetime of driving, related to 
creativity in local folk culture. First I analyze personalized license plates, 
especially those that have a mathematical flavor; then I exhibit favorite 
specimens of the diamond-shaped warning signs that traffic engineers 
have erected on highways. 

Another avocation, music, takes over in Chapter 19, where I present 
a short piece that I orchestrated for concert band when I was in high 
school. Fragments from a brief musical comedy skit that I composed 
in college appear in Chapter 20, and a pre-Christmas song that I wrote 
with my wife is the subject of Chapter 21. Chapter 22 discusses a 
remarkable algorithm due to David Kraehenbuehl that harmonizes an 
arbitrary melody in exponentially many ways. (I had great fun coaxing 
METRPOST to typeset the music in those four chapters.) 

Some readers who get to page 200 might ask, “Are we having games 
yet?” Competitive games come to center stage in Chapter 23, which 
tells the story of my undergraduate adventures with college basketball: 
I introduced math and computing into the gymnasium, and our team 
actually did well! Then Chapter 24 develops a controversial theory of 
three-person shootouts; and Chapter 25 turns to Master Mind, a game 
of logic for two players or for one player against a machine. An experi- 
mental variant of chess is the subject of Chapter 26. 

Then we get to a real computer game. Chapter 27, which is my 
all-time favorite example of a literate program, is a faithful translation 
into English and C of the original Adventure game by Crowther and 
Woods, the famous (or infamous?) time-sink that was destined to beget 
a huge gaming industry. If you want to have fun and improve your 
programming skills by reading code, this book gives you two choices, 
both of which happen to stem from some of the hilarious innovations 
devised by Don Woods in the 1970s: You can read either the illiterate 
program in Chapter 7 or the literate one in Chapter 27. 

Word play comes next. Chapter 28 recounts my first extracurricular 
escapade, which took place when I was 13 years old and entered a contest 
to find as many words as possible that could be made from a certain 
collection of letters. (Was I thinking algorithmically, and taking on big 
projects, already in those early days?) A few years later, when learning 
chemistry, I composed a short story entirely from words that made sense 
as chemical formulas at that time (see Chapter 29). Some experiments 
with typesetting during the 1980s, which in fact were featured later on 
the cover of the book Digital Typography, led to the curious cryptograms 


Preface xiii 

in Chapter 30. And Chapter 31 is a short poem that can be read in two 
ways, paradoxically losing a line in the process. 

Lewis Carroll’s popular pastime of changing one word to another, 
by modifying one letter at a time (think word ford form-foam -flam 
flay play), is the topic of Chapters 32-34. Other amusing arrange- 
ments of words into rectangles, squares, and cubes are considered in 
Chapters 35-37. 

Many of my favorite mechanical puzzles are special cases of a com- 
binatorial challenge that’s known technically as the exact cover prob- 
lem. Chapter 38 introduces the notion of “dancing links,” a simple-yet- 
important technique for dealing with such problems and with exhaustive 
searches in general. Several put-together puzzles are solved there. Ap- 
pealing constraints of another kind are considered briefly in Chapter 39. 

The most famous combinatorial pastime of all, with a continuous 
history that goes back to the 9th century, is to investigate what Martin 
Gardner has called “knights of the square table”: In what ways can a 
single knight make a tour of the entire chessboard, encountering each 
square just once? I’ve naturally been unable to withstand an impulse 
to contribute some new ideas to the vast literature that this intriguing 
question has spawned. Chapters 40-43, two of which are published here 
for the first time, contain the results of those explorations. 

Perhaps the nicest thing about knight’s tours is that they often 
yield pretty pictures. Even more beautiful, however, and mathemati- 
cally more elegant, are the “dragon curve” designs that are discussed in 
Chapters 44 and 45. Those chapters were published several years be- 
fore Benoit Mandelbrot coined the word fractal to denote what is now 
recognized as a significant family of patterns and natural phenomena. 

My wife and I have often collaborated on projects that try to tie 
together the aesthetics of art with the aesthetics of mathematics and com- 
puter science. Several of these projects, usually made just for ourselves 
or as gifts for friends, are surveyed in Chapters 46 and 47. 

Chapter 48 is a brief tribute to Martin Gardner, written shortly 
after his recent death. Oh, how I wish I could have presented him with 
a copy of this book — but without such a chapter — a few months earlier! 
Surely his spirit lives on, here and throughout the world. 

This book closes, indeed, on an upbeat note, by completing a round 
baker’s MAD of chapters. Chapter 49 is, I think, a fitting way to conclude 
the sequence of publications that began with Chapter 1. 

As in previous books of selected papers, I’ve taken the liberty here 
to correct errors of fact and of style that had appeared in the original 
publications, so that each chapter now appears in the form that I hope 


xiv Selected Papers on Fun and Games 

it will be remembered. Nearly every chapter also ends with an Adden- 
dum, which attempts to bring the material up to date with reports on 
subsequent developments. 

Now that this book is complete, I can’t help but be overwhelmed 
by an enormous feeling of gratitude. I’m truly at a loss for words to 
describe the transcendental glow that fills me at this moment. What a 
miracle it has been, to have been able to live my life at a time and place 
in which it was possible to write a book such as this! 

I’m grateful for having been able to work jointly with coauthor 
Chandler Davis on Chapter 44. My wife, Jill, was coauthor of Chapters 
21 and 45, and she contributed substantially to the material in several of 
the other chapters. Some of my research was supported by the National 
Science Foundation, the Office of Naval Research, and/or Norges Almen- 
vitenskapelige Forskningsrad. Max Etchemendy helped to prepare the 
electronic form of some of the older journal articles; then I applied spit 
and polish and handed the text to the incredible proofreading team of 
Dan Eilers, Ashutosh Mehra, Mark Ward, and Udo Wermuth. I've used 
John Hobby’s marvelous METRPOST to redraw all of the illustrations. 
Emma Pease facilitated many aspects of the production. 

This book is the eighth and final volume of my collected papers, 
published by Stanford’s Center for the Study of Language and Informa- 
tion (CSLI); I’ve been saving it up for “dessert.” It joins Literate Pro- 
gramming (1992); Selected Papers on Computer Science (1996); Digital 
Typography (1999); Selected Papers on Analysis of Algorithms (2000); 
Selected Papers on Computer Languages (2003); Selected Papers on Dis- 
crete Mathematics (2003); and Selected Papers on Design of Algorithms 
(2010). The entire series was conceived, shepherded, and masterminded 
by Dikran Karagueuzian. We plan to issue a comprehensive index to all 
eight volumes in the near future. 

In conclusion, let me close this preface by warmly thanking the KTG 
society and its fictitious leader, whose existence is sort of an enigma 
that can be deciphered only by carefully pondering the index at the rear 
of this book. Readers who are able to solve this weird puzzle will find 
that my eccentric muse was not at all able to resist the temptation 
to finish off the final preface of this eight-book series by adding some 
symbolic “book-ends,” so that the fun and games would last longer. 

Donald E. Knuth 
Stanford, California 
21114 C.D. 


Preface xv 


Acknowledgments 

“The potrzebie system of weights and measures” originally appeared in 
MAD 1 , number 33 (June 1957), pp. 36-37. Copyright ©1957 by E.C. Pub- 
lications, Inc. Reprinted by permission. 

“The revolutionary potrzebie” originally appeared in Engineering and Sci- 
ence Review: Case Institute of Technology 2, number 1 (November 1958), 
pp. 18-20. Copyright by the author. 

“The complexity of songs” originally appeared in SIGACT News 9 , num- 
ber 2 (Summer 1977), pp. 17-24. (New York: Association for Computing 
Machinery, Inc.) Copyright presently held by the author. 

“Math ace: The plot thickens” originally appeared in Engineering and 
Science Review: Case Institute of Technology 3 , number 1 (November 1959), 
p. 45; 3 , number 4 (May 1960), p. 24. Copyright by the author. 

“Billiard balls in an equilateral triangle” originally appeared in Recre- 
ational Mathematics Magazine, issue number 14 ( January-February 1964), 
pp. 20-23. (Kent, Ohio: Joseph S. Madachy, publisher.) Copyright ©1964 by 
Recreational Mathematics Magazine. Reprinted by permission of Joseph S. 
Madachy. 

“Representing numbers using only one 4” originally appeared in Mathe- 
matics Magazine 37 (1964), pp. 308-310. Copyright ©1964 by The Mathe- 
matical Association of America (Incorporated). Reprinted by permission. 

“Very magic squares” originally appeared in American Mathematical 
Monthly 75 (1968), pp. 260-264. Copyright ©1968 by The Mathematical 
Association of America (Incorporated). Reprinted by permission. 

“The Gamow-Stern elevator problem” originally appeared in Journal 
of Recreational Mathematics 2 (1969), pp. 131-137. Copyright ©1969 by 
Greenwood Periodicals, Inc. Reprinted by permission of Baywood Publishing 
Company, Inc. 

“Fibonacci multiplication” originally appeared in Applied Mathematics 
Letters 1 (1988), pp. 57-60. Copyright ©1988 by Pergamon Journals Lim- 
ited. Reprinted by permission of Elsevier Science. 

“A Fibonacci-like sequence of composite numbers” originally appeared in 
Mathematics Magazine 63 (1990), pp. 21-25. Copyright ©1990 by The Math- 
ematical Association of America (Incorporated). Reprinted by permission. 

“Transcendental numbers based on the Fibonacci sequence” originally 
appeared in The Fibonacci Quarterly 2 (February 1964), pp. 43-44, 52. Copy- 
right ©1964 The Fibonacci Quarterly. Reprinted by permission. 

“Supernatural numbers” originally appeared in The Mathematical Gard- 
ner, edited by D. A. Klarner, pp. 310-325. Copyright ©1981 by Wadsworth 
International. Reprinted by permission of Dover Publications, Inc. 

“The triel: A new solution” originally appeared in Journal of Recreational 
Mathematics 6 (1973), pp. 1-7. Copyright ©1973 by Baywood Publishing 
Company, Inc. Reprinted by permission. 


xvi Selected Papers on Fun and Games 


“The computer as Master Mind” originally appeared in Journal of Recre- 
ational Mathematics 9 (1976), pp. 1-6. Copyright ©1976 by Baywood Pub- 
lishing Company, Inc. Reprinted by permission. 

“Move It Or Lose It” originally appeared in Variant Chess 8, issue 60 
(April 2009), p. 96. (Coulsdon, Surrey: British Chess Variants Society.) Copy- 
right ©2009 by John Beasley and Donald E. Knuth. Reprinted by permission. 

“TI15E4 CH3EmIC2Al2 CasRjEr” originally appeared in Engineering and 
Science Review: Case Institute of Technology 2, number 3 (March 1959), 
p. 32. Copyright by the author. 

“N-ciphered texts” originally appeared in Word Ways 20 (1987), pp. 173- 
174, 191-192. Copyright ©1987 by A. Ross Eckler. Reprinted by permission. 

“Disappearances” originally appeared in The Mathematical Gardner, 
edited by D. A. Klarner, p. 264. Copyright ©1981 by Wadsworth Inter- 
national. Reprinted by permission of Dover Publications, Inc. 

“Lewis Carroll’s word-ward-ware-dare-dame-game” originally appeared 
in GAMES 2, issue 4 (July-August 1978), pp. 22-23. Copyright ©1978 by 
Games Publications, Inc. Reprinted by permission. 

“Blood, sweat, and tears” originally appeared in GAMES 2, issue 4 (July- 
August 1978), p. 49. Copyright ©1978 by Games Publications, Inc. Reprinted 
by permission. 

“Biblical ladders” originally appeared in The Mathemagician and Pied 
Puzzler, a collection in tribute to Martin Gardner, edited by Elwyn Berlekamp 
and Tom Rodgers (Wellesley, Massachusetts: A K Peters, 1999), pp. 29-34. 
Copyright ©1999 by A K Peters, Ltd. Reprinted by permission. 

“ETAOIN SHRDLU non-crashing sets” originally appeared in Word Ways 
27 (1994), p. 138. Copyright ©1994 by A. Ross Eckler. Reprinted by permis- 
sion. 

“Quadrata obscura” originally appeared in Word Ways 42 (2009), p. 248, 
under the title “Latin square word puzzles,” with solutions in Word Ways 
43 (2010), p. 14. Copyright ©2009, 2010 by Jeremiah Farrell. Reprinted by 
permission. 

“5x5x5 word cubes by computer” originally appeared in Word Ways 
26 (1993), pp. 95-97. Copyright ©1993 by A. Ross Eckler. Reprinted by 
permission. 

“Dancing links” originally appeared in Millennial Perspectives in Com- 
puter Science, proceedings of the 1999 Oxford-Microsoft Symposium in honour 
of Professor Sir Antony Hoare, edited by Jim Davies, Bill Roscoe, and Jim 
Woodcock (Houndmills, Basingstoke, Hampshire: Palgrave, 2000), pp. 187- 
214. Copyright ©2000 Donald E. Knuth. Reprinted by permission. 

“Uncrossed knight’s tours” originally appeared in Journal of Recreational 
Mathematics 2 (1969), pp. 155-157, as a letter to the editor. Copyright ©1969 
by Greenwood Periodicals, Inc. Reprinted by permission of Baywood Publish- 
ing Company, Inc. 


Preface xvii 


“Leaper graphs” originally appeared in The Mathematical Gazette 78 
(1994), pp. 274-297. Copyright ©1994 by The Mathematical Association, 
Leicester, U.K. Reprinted by permission. 

“Number representations and dragon curves” originally appeared in Jour- 
nal of Recreational Mathematics 3 (1970), pp. 66-81, 133-149. Copyright 
©1970 by Greenwood Periodicals, Inc. Reprinted by permission of Baywood 
Publishing Company, Inc. 

“Mathematics and art: The dragon curve in ceramic tile” originally ap- 
peared in Journal of Recreational Mathematics 6 (1973), pp. 165-167. Copy- 
right ©1973 by Baywood Publishing Company, Inc. Reprinted by permission. 

“Memories of Martin Gardner” was originally written for publication in 
Notices of the American Mathematical Society 58, number 3 (March 2011), to 
appear. Copyright ©2011 by the American Mathematical Society. Reprinted 
by permission. 

“An earthshaking announcement” originally appeared in TUGboat 31 
(2010), pp. 121-124. Copyright ©2010 T£X Users Group. Reprinted by per- 
mission. 



Chapter 1 


The Potrzebie System of 
Weights and Measures 


[Pictures by Wallace Wood. Originally published in MAD 1,33 (June 
1957), 36-37. Reprinted in William M. Gaines’s Like, MAD, edited 
by Albert B. Feldstein, Signet Pocket Books S1838 (New York: New 
American Library, 1960), 139-145. Page 36 reprinted in Completely 
MAD by Maria Reidelbach (Boston, Mass.: Little, Brown, 1991), 191. 
“The author’s first technical paper.”] 

When Milwaukee’s Donald Knuth first presented his revolutionary sys- 
tem of weights and measures to the members of the Wisconsin Academy 
of Sciences, Arts and Letters, they were astounded ... mainly because 
Donald also has two heads. All kidding aside, Donald’s system won first 
prize as the “most original presentation. ” So far, the system has been 
adopted in Tierra del Fuego, Afghanistan, and Southern Rhodesia. The 
U.N. is considering it for world adoption. 


The Potrzebie System 

This new system of measuring, which is destined to become the mea- 
suring system of the future, has decided improvements over the other 
systems now in use. It is based upon measurements taken on 6-9-12 
at the Physics Lab. of Milwaukee Lutheran High School, in Milwau- 
kee, Wis., when the thickness of MAD Magazine #26 was determined to 
be 2.2633484517438173216473 mm. This unit is the basis for the entire 
system, and is called one potrzebie of length. 

The potrzebie has also been standardized at 3515.3516 wave lengths 
of the red line in the spectrum of cadmium. A partial table of the 
Potrzebie System, the measuring system of the future, is given below. 


1 





2 Selected Papers on Fun and Games 


Length 

1 potrzebie = thickness of MAD #26 
.000001 p = 1 farshimmelt potrzebie (fp) 
1000 fp = 1 millipotrzebie (mp) 

10 mp = 1 centipotrzebie (cp) 

10 cp = 1 decipotrzebie (dp) 


Volume 

1 cubic dekapotrzebie = 1 ngogn (n) 
.000001 n = 1 farshimmelt ngogn (fn) 
1000 fn = 1 millingogn (mn) 

10 mn = 1 centingogn (cn) 

10 cn = 1 decingogn (dn) 


Mass 

1 ngogn of halavah* = 1 blintz (b) 
.000001 b = 1 farshimmelt blintz (fb) 
1000 fb = 1 milliblintz (mb) 

10 mb = 1 centiblint.z (cb) 

10 cb = 1 deciblintz (db) 


Halavah is a form 
of pie, and it has 















The Potrzebie System of Weights and Measures 3 


10 dp = 1 potrzebie (p) 

10 p = 1 dekapotrzebie (Dp) 

10 Dp = 1 hectopotrzebie (Hp) 

10 Hp = 1 kilopotrzebie (Kp) 

1000 Kp = 1 furshlugginer potrzebie (Fp) 



10 db = 1 blintz (b) 

10 b = 1 dekablintz (Db) 

10 Db = 1 hectoblintz (Hb) 

10 Hb = 1 kiloblintz (Kb) 

1000 Kb = 1 furshlugginer blintz (Fb) 


a specific gravity of 3.1416 
and a specific heat of .31416. 


10 dn = 1 ngogn (n) 

10 n = 1 dekangogn (Dn) 

10 Dn = 1 hectongogn (Hn) 

10 Hn = 1 kilongogn (Kn) 

1000 Kn = 1 furshlugginer ngogn (Fn) 


4 Selected Papers on Fun and Games 



Time 

1 average rotation of the 
earth = 1 clarke (cl) 
.00000001 cl = 1 wolverton (wl) 
1000 wl = 1 kovac (kov) 

100 kov = 1 martin (mtn) 

100 mtn = 1 wood (wd) 

10 wd = 1 clarke (cl) 

10 cl = 1 mingo (mi) 

10 mi = 1 cowznofski (cow) 

Date 


October 1, 1952 is the day MAD 
was first published according to 
the old calendar. On the new cal- 
endar, this is clarke 1 of cowznof- 
ski 1. Cowznofskis before this date 
are referred to as “Before MAD 
(B.M.)” and cowznofskis following 
this date are referred to as “Cowz- 
nofsko Madi (C.M.).” The calen- 
dar for each cowznofski contains 10 
mingos named as follows: 1. Tales 
(Tal.) 2. Calculated (Cal.) 3. To 
(To) 4. Drive (Dri.) 5. You (You) 
6. Humor (Hum.) 7. In (In) 8. A (A) 
9. Jugular (Jug.) 10. Vein (Vei.) 



> 

k*. . ' > 


The Potrzebie System of Weights and Measures 5 


Force (absolute) 

A force which, when actin 
for 1 kovac, causes it to 
of 1 potrzebie per kova. 

1000000 b-al = 1 fu* 

Energy and Work 

1 blintzal-potrzebie = 1 

i onnnoo h = 1 bah ^b) 


Power 

1 hah per kovac 

1000 WMW = - 
100 KWMW = 


(WMW) 

(KWMW) 


_ 1 whatmeworry 

L folowhatmeworry 

1 aeolipower (A.P. 


Radioactivity 

The quantity of i 
1 blintz of rad 


vhich is in equilibrium 

1 hyme (how’s your m 


Temperature 

100° Smurdley (S) — 
Tiprature for eating 


optimum tem- 
halavah (27° C) 



6 Selected Papers on Fun and Games 




Heat Energy 

The amount of heat necessary to raise 1 
blintz of halavah 1° S = 1 vreeble (v) 

1000 v = 1 large vreeble (V) 

Counting 

48 things = 1 MAD 

49 things = 1 baker’s MAD 

Angular Measure 

100 quircits ("") = 1 zorch ('") 

100 zorch ('") = 1 zygo (§) 

100 zygo (§) = 1 circle or circumference 

Miscellaneous Measurements 

speed of light = 114441 Fp/kov 
1 light cowznofski = 1.14441 x 10 12 Fp 
1 vreeble = 574.8 hah 
1 cosmo per square potrzebie = 3.1416 bumbles 
1 faraday = 122400 blobs/blintz equivalent weight 
1 electron-ech = 5.580 x 10“ 15 hoo 
1 blintz molecular weight of a gas = 70.4 Kn 
density of H 2 O = .3183 blintzes per ngogn (distilled water) 

1 atmosphere pressure = 1.4531 b/p 2 = 335.79 p of Hg 
gravity = 3234.4 p per kov per kov 
downward force of 1 b = 3234.4 b-al 

Basic Conversion Factors (abbreviated table) 

1 inch = 11.222 potrzebies 
1 mile = .71105 furshlugginer potrzebies 
1 potrzebie = 2.2633 millimeters = .089108 inches 
1 furshlugginer potrzebie = 2.2633 kilometers = 1.4064 miles 
1 centimeter = 4.4182 potrzebies 
1 kilometer = .44182 furshlugginer potrzebies 
1 ngogn = 11.59455 cc = .012252 quarts = 2.3523 teaspoons 
1 blintz = 36.42538361 grams 
1 kiloblintz = 80.3042 pounds 
1 furshlugginer blintz = 36.425 metric tons 
1 wood =144 minutes 
1 kovac = .864 seconds 
1 year = 3.6524 cowznofskis 
1 watt = 3.456482 whatmeworries 
1 horsepower = 2.58 kilowhatmeworries 
1 aeolipower = 38.797 horsepower 
1 vreeble = 34.330 calories 




The Potrzebie System of Weights and Measures 


7 



225 LAFAYETTE STREET • NEW YORK 12, NEW YORK • CANAL 5-1894 

February 18 , 1957 

Mr. Don Knuth 

71j. 36 W. Caldwell A re. 

Milwaukee 16, Wise. 

Dear Don, 

Surprise. 

Bet you thought we forgot all about you. 

Actually, we held off "Potrzebie System" for two issues 
pending the realignment of our talent. We then made the 
changes necessary, and... 

It's coming out in MAD #33. 

Illustrated by Wood. 

Credited to you. 

So, enclosed is a cheek for $25.00 for the rights to 
print it in MAD, with the slight changes. 

Also, enclosed is a copy of No. I 4 ., which you said you 
didn't hare. No. 5 wo don't even have* 

Thanks again for letting us use your revolutionary 
measuring system. We're sure its inclusion in MAD 
will mean absolutely nothing to the world of soienoe. 

A1 Feldstein^ 

Editor 



8 Selected Papers on Fun and Games 

Addendum 

When I devised this system in 1955 I had absolutely no idea what the 
word ‘potrzebie’ signified, if anything. I knew it only as a strange- 
looking jumble of letters that had been appearing regularly in MAD as 
a staple element of random weirdness.* Shortly afterwards, in college, 
I learned that it is a not-uncommon word in Polish. Friends later sent 
me a clipping from page 1A of The Milwaukee Journal dated Sunday, 
19 November 19 1989, which began with the following banner headline: 

‘Nasza ziemia znow w potrzebie’ 

( Our homeland is again in need — Lech Walesa) 

The MAD typesetters accidentally dropped out a digit from the 
true number of millimeters per potrzebie; they printed it incorrectly as 
‘2.263348517438173216473’. In a letter to the editor of the Case Tech in 
1959, I pointed out that the correct number is easily memorized: 

Just remember the poem “If by doubts you are much dismayed, 
this rhyme, a helping hand, was purveyed.” Then, assuming 
you can spell “purveyed,” just count the letters in each word 
and you get 2.2633484517438, correct to 14 places. 

I’m pleased to have this opportunity to set the record straight, after more 
than 50 years. Readers who wonder where this fundamental constant 
arose should try to calculate the exact number of potrzebies in 9 inches, 
using the United States standard inch that was in force when I made 
the crucial initial measurements. f 


* ‘Potrzebie’ made its debut on the letters page of MAD #10 (April 1954), 
when a reader wrote “Please tell me what in the world ‘Furshlugginer’ 
means.” Editor Kurtzman replied, “It means the same as Potrzebie.” One 
month later, Jack Davis included the word in his contribution to MAD #11; 
Will Elder, Bernard Krigstein, and Wallace Wood followed suit in #12. 
Then #13 printed letters from four different readers, asking respectively 
for definitions of ‘furshlugginer’, ‘potrzebie’, ‘blintzes’, and ‘halavah’. An- 
swer: Perhaps it might be all explained by illustrating the usage of the words 
in question, such as, “Who stuffed the furshlugginer blintzes with halavah? 
They taste like potrzebie!” 

f Between 1893 and 1959, the famous Mendenhall rule stipulated that 1 me- 
ter equals 39.37 US inches, exactly. A simpler standard, the international 
inch — which is precisely 2.54 cm — was adopted in America on 1 July 1959. 


Chapter 2 


Official Tables of the Potrzebie System 


[The notes below, dated “Jugular 2, 13” (4 April 1956), were privately 
distributed in mimeographed form to members of the Wisconsin Junior 
Academy of Science in 1956. They served as the source from which MAD 
editors subsequently extracted the article in the previous chapter.] 


The Potrzebie System of Weights and Measures 

This new system of measuring, which is destined to become the mea- 
suring system of the future, has decided improvements over the other 
systems now in common use. It is based upon measurements taken on 
6-9-12 at the Physics Lab of Milwaukee Lutheran High School, Milwau- 
kee, Wis., when the thickness of MAD Magazine #26 was determined 
to be 2.26334 84517 43817 32164 73780 74941 60547 91419 5114 mm. This 
unit is the basis for the entire system, and is called one potrzebie of 
length. The potrzebie has also been standardized at 3515.3516 wave 
lengths of the red line in the spectrum of cadmium. A complete table 
of the Potrzebie System is given below. 

Length (see ruler at right) 

1 potrzebie = thickness of MAD #26 
.000001 p = 1 farshimmelt potrzebie (fp) 

1000 fp = 1 millipotrzebie (mp) 

10 mp = 1 centipotrzebie (cp) 

10 cp = 1 decipotrzebie (dp) 

10 dp = 1 potrzebie (p) 

10 p = 1 dekapotrzebie (Dp) 

10 Dp = 1 hectopotrzebie (Hp) 

10 Hp = 1 kilopotrzebie (Kp) 

1000 Kp = 1 furshlugginer potrzebie (Fp) 


9 


10 Selected Papers on Fun and Games 

Volume 

1 cubic dekapotrzebie = 1 ngogn (n) 

.000001 n = 1 farshimmelt ngogn (fn) 

1000 fn = 1 millingogn (mtn) 

10 mtn = 1 centingogn (cn) 

10 cn = 1 decingogn (dn) 

10 dn = 1 ngogn (n) 

10 n = 1 dekangogn (Dn) 

10 Dn = 1 hectongogn (Hn) 

10 Hn = 1 kilongogn (Kn) 

1000 Kn = 1 furshlugginer ngogn (Fn) 

Mass 

1 ngogn of halavah* = 1 blintz (b) 

.000001 b = 1 farshimmelt blintz (fb) 

1000 fb = 1 milliblintz (mb) 

10 mb = 1 centiblintz (cb) 

10 cb = 1 deciblintz (db) 

10 db = 1 blintz (b) 

10 b = 1 dekablint.z (Db) 

10 Db = 1 hectoblintz (Hb) 

10 Hb = 1 kiloblintz (Kb) 

1000 Kb = 1 furshlugginer blintz (Fb) 

Time 

1 average rotation of the earth on its axis = 1 price (pr) 
.00000001 pr = 1 wolverton (wl) 

1000 wl = 1 severin (sev) 

100 sev = 1 davis (dv) 

100 dv = 1 wood (wd) 

10 wd = 1 price (pr) 

10 pr = 1 elder (el) 

10 el = 1 kurtzman (k#) 


Date 

October 1, 1952 is the day MAD was first published according to the old 
calendar. On the new calendar this is price 1 of kurtzman 1. Kurtzmans 


* Halavah is a form of pie, and it has a specific gravity of 3.1416 and a specific 
heat of .31416. 


Official Tables of the Potrzebie System 11 

before this date are referred to as “Before MAD (B.M.)” and kurtzmans 
after this date are referred to as “ Kurtzmano Madi (K.M.).” The calen- 
dar for each kurtzman contains 10 elders named as follows: 


1 Tales (Tal.) 

2 Calculated (Cal.) 

3 To (To) 

4 Drive (Dri.) 

5 You (You) 


6 Humor (Hum.) 

7 In (In) 

8 A (A) 

9 Jugular (Jug.) 
10 Vein (Vei.) 


Force (absolute) 

A force which, when acting upon 1 blintz of mass for 1 severin, 
causes it to attain a velocity of 1 potrzebie per severin 
= 1 blintzal (b-al) 

1000000 b-al = 1 furshlugginer blintzal (Fb-al) 

Energy and Work 

1 blintzal-potrzebie = 1 hoo (h) 

1000000 h = 1 hah (hh) 

Power 

1 hah per severin = 1 whatmeworry (WMW) 

1000 WMW = 1 kilowhatmeworry (KWMW) 

100 KWMW = 1 aeolipower (A.P.) 

Temperature 

100° Smurdley (S) = optimum temperature for eating halavah (27° C) 

0° S = absolute zero 

Heat Energy 

The amount of heat necessary to raise one blintz of halavah 1° S 
= 1 vreeble (v) 

1000 v = 1 large vreeble (V) 

Light Energy 

The intensity in a given direction of one square potrzebie of surface 
of a black body radiator at the temperature of freezing platinum 
(about 681° S), the surface being normal to the given direction, 
= 1 cosmo (cos) 


12 Selected Papers on Fun and Games 

The luminous flux produced in a solid angle of one steradian by 
a uniform point source of one cosmo at the vertex of the angle 
= 1 shermlock (shr) 

The quantity of light that passes a cross section of a beam of light 
in one severin when the flux is one shermlock 
= 1 shermlock-severin (shr-sev) 

The illumination on a surface all points of which are at a distance 
of 1 kilopotrzebie from a uniform point source of one cosmo 
= 1 kilopotrzebie-cosmo, or potcosmo (pc) 

The average brightness of a surface emitting or reflecting light at the 
rate of one shermlock per square dekapotrzebie of actual surface 
= 1 bumble (bum) 

(The prefixes used in mass, volume, and length units are applied to all 
these units and those following to show larger or smaller quantities.) 

Magnetism and Electricity 

a. Magnetic Pole Strength. The strength of a pole that will repel 

an equal like pole at a distance of one potrzebie in a vacuum 
with a force of one blintzal 
= 1 klek 

b. Magnetic Field Intensity. The intensity of a magnetic field 

at a point when a pole of one klek placed at the point is 
acted upon by a force of one blintzal 
= 1 hester (hes) 

c. Magnetic Flux Density. The flux density of a magnetic field 

at a point in a vacuum when the field intensity at that 
point is one hester 

= 1 schvester (sch), also called 1 bentney per square potrzebie 

d. Magnetic Flux. The amount of magnetic flux in a square 

potrzebie of area when the flux density is one schvester 
= 1 bentney (ben) 

10 <J bentneys = 1 kilofurshlugginer bentney (KFB) 

e. Magnetomotive Force. The magnetomotive force producing the 

flux when one hoo of work is required to move a pole of one klek 
completely around a magnetic circuit against the field intensity 
= 1 gookum (gk)* 

f. Magnetic Reluctance. The reluctance of a magnetic path one 

potrzebie in length with a cross-sectional area of one square 


* Also measured in ganef-turns, where 1 ganef-turn = 12.566 gk. 


Official Tables of the Potrzebie System 13 

potrzebie and the permeability of a vacuum 
= 1 hex 

g. Electric Current. The electric current that, in a wire 

one potrzebie long at right angles to a magnetic field of 
one schvester, is acted upon by a force of one blintzal 
at right angles to the current and the flux 
= 1 ganef (gan) 

h. Electric Quantity. The quantity of electricity that passes 

the cross-section of a conductor when a current of one ganef 
is maintained for one severin 
= 1 blob 

i. Electric Potential and Electromotive Force. The electromotive 

force induced in a coil of one turn when the flux changes 
through it at the rate of one bentney per severin 
= 1 farshimmelt ech (f-ech) 

One ech (secondary definition) is the potential difference 
between two points when one hah of work is required to 
carry a charge of one blob from the first point to the second 

j. Electric Resistance. The resistance of a conductor in which 

a current of one ganef is maintained by a potential difference 
of one ech 
= 1 heap 

k. Electric Resistivity. The resistivity of a material when the 

resistance between the opposite faces of a cubic potrzebie 
of the material is one heap 
= 1 heap-potrzebie 

l. Electric Conductance. The conductance of a conductor that 

has a resistance of one heap 
= 1 paeh 

m. Electric Conductivity. The conductivity of a material that 
has a resistivity of one heap-potrzebie 

= 1 paeh per potrzebie 

n. Electric Inductance. The self-inductance of a coil in which a 

back electromotive force of one ech is induced when the current 
in the coil changes at the rate of one ganef per severin 
= 1 schmetnik (smn) 

o. Electric Capacitance. The capacitance of a condenser that, 

when charged with one blob of electricity, has a potential 
difference of one furshlugginer ech between its plates 
= 1 flip 


14 Selected Papers on Fun and Games 

p. Electrostatic Quantity. The quantity of electricity that will 

repel an equal like quantity at a distance of one potrzebie 
in a vacuum with a force of one blintzal 
= 1 glob* 

q. Electric Kinetic Energy. The kinetic energy of an electron that 

has fallen freely through a potential difference of one ech 
= 1 electron-ech 

Radioactivity 

The quantity of radon in equilibrium with one blintz of radium 
= 1 hyme (how’s your mom, ed) 

Angular Measure 

100 quircits ("") = 1 zorch ('") 

100"' = 1 zygo (®) 

100® = 1 circle or circumference 

Counting 

64 things = 1 MAD 

65 things = 1 baker’s MAD 

Lens Strength 

The power of a lens whose focal length is one kilopotrzebie 
= 1 glarf 

Miscellaneous Measurements 

density of H 2 O = .31831 blintzes per ngogn 

1 atmosphere pressure = 1.4531 b/p 2 = 335.79 p of Hg 

1 b downward force = 3234.4 b-al 

gravity = 3234.42243 p per sev per sev 

speed of light = 114441 Fp/sev 

1 light k# = 1.14441 x 10 12 Fp 

1 year = 3.6524 k# 

1 faraday = 122400 blobs/blintz equivalent weight 
1 blob = 1.14441 x 10 11 globs 
1 glob = 1.5660 x 10 9 electrons 
1 blob = 1.792 x 10 2 ° electrons 
1 electron-ech = 5.580 x 10~ 15 hoo 


The other units of current electricity are used in electrostatics also. 


Official Tables of the Potrzebie System 15 

Basic Conversion Factors 

1 p = 2.2633 mm = .089108 in 
1 Fp = 2.2633 km = 1.4064 mi 
1 cm = 4.4182 p; 1 km = .44182 Fp 
1 in = 11.222 p; 1 mi = .71105 Fp 
1 acre = 789.9779 square Kp 

1 n = 11.59455971 cc = 11.59424 ml = .012252 qt = 2.3523 teaspoons 
1 b = 36.42538361 g = 1.28487 oz 
1 Kb = 80.3042 lb; 1 cb = 5.6213 grains 
1 Fb = 36.425 metric tons = 40.152 T 
1 g = 27.453 mb; 1 lb = 12.4526 b 
1 wd = 144.000 min; 1 sev = .864000 sec 
1 b-al = 11.04404251 dynes 
1 poundal = 1251.85 b-al 
1 erg = .400055743 h; 1 joule = 4.00056 hh 
1 h = 2.4996516525 erg 
1 watt = 3.456481623 WMW 
1 H.P. = 2.5775 KWMW 
1 A.P. = 38.797 H.P. 

S = §(C + 273.15) = ^(F + 459.67) 

F = 5.4S - 459.67; C = 3S - 273.15 
1 v = 34.330 calories; 1 B.T.U. = 7.35 v 
1 vreeble = 574.8 hah 
25®” = right angle; 1® = 3.6° 

1"' = 2.16' = .64 mil; 1"" = 1.296" 

1 radian = 15® 91'" 55"" or 15:9155 
1 candle = .32535 cosmo; 1 cosmo = 3.0736 candle 
1 shermlock = 3.0736 lumen 

1 pc = .055742 footcandle; 1 footcandle = 17.94 pc 
1 pc = .60000 lux; 1 Fpc = 60 phot 
1 bumble = .60000 lambert 
1 cosmo per square potrzebie = 3.1416 bum 
1 klek = .75217 unit pole 
1 hester = 14.683 oersteds 
1 schvester = 14.683 gauss or line/cm 2 
1 ben = .75217 maxwell; 1 KFB = 7.5217 webers 
1 gk = 3.3233 gilberts 
1 hex = 4.4182 rowlands 
1 ganef = 33.23257816 amperes 
1 blob = 28.71294753 coulombs 


16 Selected Papers on Fun and Games 

1 kiloech = 8.705660224 volts 
1 kiloheap = .2619616264 ohm 

1 heap-potrzebie = .000059291 ohm-cm = 356.65 ohm/mil ft 
1 paeh = 3817.4 mhos 
1 paeh per potrzebie = 16866 mho/cm 
1 smn = .00022633 henry 
1 flip = .003298193 farad 
1 glob = .7521690433 statcoulomb 
1 hyme = 36.425 curies 
1 glarf = .44182 diopter 

Date Conversion 

A.D. 

10- 1-1952 

11- 5-1953 
3-20-1955 
8-1-1956 

12- 14-1957 
11-9-1979 


= New Kurtzman’s Day of K.M. 

1 

5 

10 

15 

20 

100 



Official presentation of the system on 5 May 1956 
(photo by Ervin Knuth) 



Official Tables of the Potrzebie System 
pngganiniiiiiiiaigimiiiii m^ 

(Eire ffiiscmism jfuniar Acaftemo nf jS’cicttre 

Certificate of iflerit 


17 


— DONALD KNUT H 

Jn recognition of excellent &inrk in science 

presented at the STATEWIDE meeting of tl|e 

iUisconsin junior JVrabemo of Science hnrin g 1 9 5 6 , 





Wm h. 




Addendum 

A well-written article entitled “‘Science’ Has Odd Tongues: ‘Ngogns’ 
Take Over” appeared in The Milwaukee Journal on Sunday, 6 May 1956, 
part 2, column 1 of page 15. The anonymous reporter did an exception- 
ally good job of explaining all of the Potrzebie System’s key features, 
especially considering the fact that my presentation had been given late 
in the afternoon on the previous day. [See also John W. Thomson, Jr., 
“Junior Academy news,” Wisconsin Academy Review 3 (1956), 129.] 

Notice that my 1955 names for the units of time were severin (sev), 
davis (dv), wood (wd), price (pr), elder (el), and kurtzman (k#), honor- 
ing many of the major contributors to MAP’s early issues.* Those units 
later became respectively kovac (kov) , martin (mtn) , wood (wd) , clarke 
(cl), mingo (mi), and cowznofski (cow), because of personnel changes at 
MAD headquarters during 1956. 

Modern readers may be surprised by the distinction between milli- 
liters and cubic centimeters in the conversion table, because interna- 
tional standards have changed. Between 1901 and 1964, a “liter” was 
defined to be the volume of one kilogram of pure water under standard 
atmospheric pressure, at the temperature where water becomes most 
dense; this meant that a liter was approximately 1000.028 cc. [See the 
definition of “litre” in the Oxford English Dictionary for several relevant 
quotations.] 


* Students of the very first issues of MAD will wonder why I passed up the 
opportunity to measure temperature in “degrees Melvin” instead of degrees 
Smurdley. The reason is simple: I had friends named Melvin. 


18 Selected Papers on Fun and Games 

Thus a liter of halavah weighed exactly 7r kilograms in 1955, and I 
wish to maintain this exact relation with respect to the new standard 
in which one liter equals exactly 1000 cc. Accordingly, I now define the 
blintz in such a way that 1 cc of halavah weighs precisely n grams. 

Similarly, I now define time units in such a way that 1 day equals 
precisely 86400 international standard seconds. 

With these conventions, essentially all of the conversion factors in 
the basic table above can in principle be computed to arbitrary precision, 
using the infinitely precise value of 6 = 2.2633 . . . suggested in the ad- 
dendum to the previous chapter. For example, 9 3 — 11.59 . . . is the num- 
ber of cc per ngogn; 9 3 n = 36.425 ... is the number of grams per blintz. 
The number of dynes per blintzal is \ — 10 5 # 4 7r/864 2 = 11.044 . . . , and 
there are 100/(#x) = 4.000557. . . hah per joule. Electromagnetic con- 
version factors like 10\/x — 33.23 . . . , the number of amperes per ganef, 
and 9\fx! 10 = .752169..., the number of maxwells per bentney, are 
trickier but still doable. 

I made a dozen or so rounding errors in my original computations, 
most notably when I took absolute zero to be Lord Kelvin’s original ap- 
proximation — 273° C instead of the standard value —273. 15° C. More se- 
rious were my erroneous calculations of poundals, mils per quircit, and 
ohms per mil- foot. All of those mistakes have been corrected in the ta- 
bles presented above, which should be regarded as completely definitive 
for the Potrzebie System except with respect to the units of counting 
and time, and the conventions of the new calendar. Revised definitions 
of the latter quantities appear in the next chapter. 


Chapter 3 


The Revolutionary Potrzebie 


[Originally published in Engineering and Science Review, Case Institute 
of Technology, 2,1 (November 1958), 18-20.] 


The units for measuring mass, time, and many other quantities are basic 
tools of every engineer and scientist. Unfortunately, the hodgepodge of 
units in existence today is so inconvenient and confusing that thousands 
of man-woods, that is, man-hours, are wasted in converting one unit 
into another. 

Engineers must first spend their time learning the screwball English 
system — where there are 12 inches to a foot, 16 ounces in a pound, 
and absolute zero is approximately —459.67 degrees. Then they learn 
the metric system, which contains different units for the same quantities 
already measured in the English system. They discover that the metric 
system has a definite advantage because it is based on powers of 10, for 
easy calculation; yet even in this system there are 60 minutes in an hour, 
24 hours in a day, and 365.2422 days in a year. A cubic centimeter does 
not equal a milliliter. And in electricity the metric system is split into 
three separate systems, electrostatic, electromagnetic, and “MKS.” In 
summary, they find that the whole situation is a furshlugginer mess. 

How do we solve the difficulty? The Potrzebie System comes to 
our rescue. Once it has been adopted, the world will at last have one 
good, consistent, and practical system of units. (Until then, however, 
it just adds to the general confusion.) Great strides are being made by 
enterprising governments around the globe: The Potrzebie System has 
already been adopted in Lichtenburg; Perdido County, Texas; Tierra del 
Fuego; and both Northern and Southern Rhodesia. In fact, the United 
Nations is soon to consider it for world adoption. 


20 Selected Papers on Fun and Games 

Humble Beginnings 

At the very beginning, let us decide to pronounce the name right: potter- 
zee-bee. A potrzebie (p) is the basic unit of length for the system; 
this measurement was absolutely determined on day 1158 in Milwaukee, 
Wisconsin, when the thickness of MAD Magazine number 26 was found 
to be 2.26334 84517 43817 32164 73780 74941 60547 91419 5114 mm. 
This length is defined to be one potrzebie (which is also standardized as 
3515.3516 wave lengths of the red line in the cadmium spectrum). The 
total height of the page you are reading is approximately 100 p, and the 
right edge of the previous page contains a ruler for other measurements. 

When larger units are desirable, the dekapotrzebie (Dp) is equal 
to ten potrzebies; a hectopotrzebie (Hp) equals 100 p; a kilopotrze- 
bie (Kp), 1000 p; and a furshlugginer potrzebie (Fp) is 1,000,000 p. 
For smaller units we have the decipotrzebie (dp) equal to one-tenth of a 
potrzebie; a centipotrzebie (cp), which is .01 p; a millipotrzebie (mp) 
equal to .001 p; and a farshimmelt potrzebie (fp), .000001 p. Similar 
prefixes are applied to any other units of the system when larger or 
smaller units are desired. For very small measurements of distance, the 
Neuman Unit (N), equal to one millionth of a farshimmelt potrzebie, is 
used. The distance from Cleveland to Sandusky is about 42 furshlugginer 
potrzebies. In Russia, one verst equals 471.34 kilopotrzebies; in ancient 
Greece, one “stadium” was equal to 81.88 Kp. 

Next come the units of volume. One ngogn (n) is defined to be 
a cubic dekapotrzebie. As a result, one ngogn equals .012252 quarts, 
11.59455971 cc, or 11.594235 ml. In the kitchen, an ngogn is approx- 
imately 2.3523 teaspoons (and in Japanese kitchens, one koku equals 
16 Kn). One bushel is 3.0393 kilongogns. 

The potrzebie unit of mass is defined in terms of volume units and 
the theoretical substance, halavah. Halavah is a form of pie, so it has a 
specific gravity of approximately 3.1415927. One ngogn of halavah has, 
by definition, a mass of one blintz (b). Thus a blintz is 1.28487 ounces 
or 36.42538361 grams. 

Let’s take a breather for a minute and consider the new units of 
counting: 

48 things = 1 MAD 

49 things = 1 baker’s MAD 

Already we have enough units defined to see that the density of 
water is .31831 blintzes per ngogn, and that one atmosphere of pressure 
is 1.4531 blintzes per square potrzebie (or 335.79 potrzebies of mercury). 


The Revolutionary Potrzebie 21 


One “blintz molecular weight” of a gas is 70.4 kilongogn; Avogadro’s 
number becomes 2.19 x 10 25 molecules per blintz-mole. 

Time and New Calendar 

The Potrzebie System features a revolutionary new improvement in the 
units of time. Each day is broken into ten periods called “woods” ; each 
wood (wd) contains 100 martins (mtn); and a hundredth of a martin is 
a kovac (kov). One wood is 144 minutes; a second is 1.1574 kovacs. The 
new, decimal clock is pictured at the time corresponding to 2:15 p.m. 



A logical, decimal chronometer 
shown at .59375 o’clock. 


Longer periods of time are reckoned using a new calendar. It is 
absurd to attempt to make the year of days coincide with the year of 
seasons, for the two are incommensurable. Our present calendar, for 
example, becomes another day out of step with the seasons every 3,323 
years. For this reason, the potrzebie “year” is taken to be exactly 100 
days long. No leap years, no “thirty days hath September” rhymes, no 
muss, no fuss; and birthdays come almost four times as often. 

The potrzebie year is called a cowznofski (cow), and it is divided 
into ten 10-day periods called mingos. The rningos in every cowznofski 
are numbered from 0 to 9, and the days in each mingo are also numbered 
from 0 to 9 rather than from 1 to 10. In this manner, each day can be 
represented by a two-digit number from 00 to 99. The new calendar is 
illustrated on the next page with the names of each mingo. Date 00 
cowznofski 0 was October 1, 1952, in the Gregorian calendar; cowznof- 
skis preceding this date are referred to as Before MAD (B.M.) and 
those after this date are designated by the Latin phrase Cowznofsko 
Dimentii (C.D.), “in the cowznofski of MAD.” December 1, 1958, is 
therefore Humor 2, 22 C.D. by the new calendar. 


22 Selected Papers on Fun and Games 

The next New Cowznofski’s Day will be celebrated on January 18, 
1959 when we burst into cowznofski number 23 (after a big party on New 
Cowznofski’s Eve). Christmas is celebrated every 100 days as the date 
Jugular 1, since Christ was born on Jugular 1, 7144 B.M. Other holidays 
in the United States are Washington’s Birthday (To 5, 806 B.M.); In- 
dependence Day (To 9, 644 B.M.); Columbus Day (Tales 9, 1680 B.M.); 
and Armistice Day (To 2, 124 B.M.). 


The Cowznofski Calendar 


0 : TALES 


|"o" 

1 

2 

3 

4 

5 

6 

7 

8 

9 


2 : TO 


0 

1 

2 

3 

4 

5 

6 

7 

8 

9 


4 : YOU 


0 

1 

2 

3 

4 

5 

6 

7 

8 

9 


6 : IN 


0 

1 

2 

3 

4 

5 

6 

7 

8 

9 


8 : JUGULAR 


0 


2 

3 

4 

5 

6 

7 

8 

9 


1 : CALCULATED 


0 

i 

2 

3 

4 

5 



6 

7 

8 

9 


3 : DRIVE 


0 

1 

2 

3 

4 

5 

6 

7 

8 

9 


5 : HUMOR 


0 

1 

2 

3 

4 

5 

6 

7 

8 

9 


7 : A 



Since the entire scheme of time reckoning is at last completely deci- 
mal, we can specify a moment of history with a single decimal number. 
For example, 2271.65498 would mean “54 martins and 98 kovacs past 6 
woods on day 71 of cowznofski 22” — which corresponds to 43 minutes 
and 10.272 seconds past 3 p.m. on December 20, 1958. The opening 
words of Lincoln’s Gettysburg address can be rewritten as “Six MAD 
and thirty-one cowznofskis ago, our fathers brought forth . . . .” 

The acceleration of gravity is 3234.4 potrzebies per kovac squared 
in the new system and the speed of light is 114,441 furshlugginer potr- 
zebies per kovac. Astronomical distances can now be measured in light 
cowznofskis, where one light cowznofski equals 1.14441 x 10 12 Fp. 












The Revolutionary Potrzebie 23 


Force, Work, Energy, Power 

Units of force, work, and power are derived in the usual way from units 
of mass, length, and time: One blintzal is the amount of force that, 
when acting upon one blintz of mass for one kovac, causes it to attain a 
velocity of one potrzebie per kovac. A blintzal-potrzebie is one hoo (h), 
the unit of work and energy; one million hoo equals one hah (hh). We 
also define one hah of work per kovac to be one whatmeworry (WMW) 
of power. A kilowhatmeworry is, of course, 1000 WMW; a special 
unit of power, the aeolipower (A.P.), is equal to 100 KWMW. From 
these definitions we see that a blintzal is 11.04404251 dynes, a joule is 
4.00055743 hah, and one aeolipower is 38.797 horsepower. 

Heat energy has units of its own. The potrzebie temperature scale 
is an absolute scale measured in degrees Smurdley (° S). Zero degrees 
Smurdley is absolute zero; 100° S is the “optimum temperature for eat- 
ing halavah” — which comes to exactly 26.85 degrees Centigrade. From 
this definition we obtain the fact that temperature in degrees Smurd- 
ley is the Centigrade temperature plus 273.15 divided by three. Thus, 
water freezes at 91.05° S and boils at 124.38° S, and the “normal” hu- 
man temperature, 98.6° F, is 103.4° S. Heat energy then is measured in 
Potrzebie Thermal Units (P.T.U.) or vreebles (v), where a vreeble is 
the amount of heat that raises the temperature of one blintz of halavah 
by one degree Smurdley. Halavah is known to have a specific heat of 
.31415927 independent of its temperature. Diet- watchers no longer have 
to count calories; they can count vreebles instead: One large calorie is 
29.13 vreebles, and one B.T.U. is 7.35 v. For the mechanical equivalent 
of heat we find that one vreeble equals 574.8 hah. 

The new unit of light intensity is the cosmo, named after the bril- 
liant Cosmo McMoon. One cosmo is the intensity of a square potrzebie 
of surface of a black body radiator at the temperature of freezing plat- 
inum (681° S), in a direction normal to the surface. An axolotl is the 
illumination on a surface that is one kilopotrzebie away from a point 
source of one cosmo. (One cosmo equals 3.0736 candles; one footcandle 
is 17.94 axolotl; one axolotl is .60 lux.) One glarf is the focal power of a 
lens that has a focal length of one kilopotrzebie (namely .44182 diopters). 

Magnetism and Electricity Get Theirs 

Yes, there are new units of electricity also. Unfortunately the definitions 
of these units are even more tedious than the ones that have already 
been given; non-electrical engineers may do well to skip this section 
completely! Here are the gory details; we start with magnetism: A 


24 Selected Papers on Fun and Games 

theoretical magnetic pole of one klek will repel an equal like pole, which 
is one potrzebie away in a vacuum, with a force of one blintzal. The 
bentney is the magnetic flux in a square potrzebie of area when the 
flux density is such as to cause a one klek pole to be acted upon by one 
blintzal of force. Now we get to electric current: A current of one ganef 
is the current that is acted upon by a force of one blintzal per potrzebie 
of wire length when normal to a magnetic field of one bentney per square 
potrzebie. The quantity of charge that passes through a conductor when 
a current of one ganef is maintained for one kovac is a blob. One ech 
is the potential difference between two points when one hah of work is 
required to carry a charge of one blob from the first point to the second. 
With these definitions in hand, we stop to observe a byproduct of our 
choices of definitions so far: The electromotive force induced in a coil 
of one turn when the flux changes through it at the rate of bentney per 
kovac is one farshimmelt ech. (Proof of this is left to the reader.) 

Resistance is calculated in “heaps,” where one heap is the resistance 
of a conductor when a ganef of current is maintained by a potential of one 
ech. Conductance is therefore measured in paehs. The self-inductance 
of a unit coil, in which a back electromotive force of one ech is induced 
when the current in the coil changes at the rate of one ganef per kovac, 
is one schmetnik. The capacitance of a unit condenser, which has a 
potential difference of one furshlugginer ech between its plates when 
charged with one blob of electricity, is one flip. Finally we have the 
glob for static electricity: The force between two globs of charge, when 
they are one potrzebie apart in a vacuum, is one blintzal. 

As a consequence of these definitions we find the following conversion 
factors: 


1 bentney = .7521690433 maxwells 
1 ganef = 33.23257816 amperes 
1 blob = 28.71294753 coulombs 


1 kiloech 
1 kiloheap 
1 heap-potrzebie 
1 paeh 
1 schmetnik 
1 flip 
1 glob 
1 blob 
1 electron-ech 


= 8.705660224 volts 
= .2619616264 ohm 
= 356.65 ohms per mil foot 
= 3817.352999 mhos 
= .0002263348 henry 
= .0032981930 farad 
= .7521690433 statcoulomb 
= 1.14441 x 10 11 globs 
= 5.580 x 10- 15 hoo 


Faraday’s constant 


122,400 blobs per blintz-equivalent-weight 


The Revolutionary Potrzebie 25 

More Still 

Many more units, of the obscure variety, round out the Potrzebie System 
so that actually all existing units are wiped out. They are too numerous 
to be catalogued here, but examples are the furd (unit of viscosity), the 
egr (ech-ganef-reactance, to replace the “var”), and the hyme (“how’s 
your mom, ed” — the unit of radioactivity) . 

As soon as our computer has figured out Planck’s constant in the 
new units, the system will be finished. Meanwhile we suggest that every- 
one either throw away all of the old textbooks in sight, or write new units 
in place of the old wherever they appear, in preparation for future years 
when the Potrzebie System will make all the present measures obsolete. 
All kidding aside, I am sure that the reader will find it very instructive 
to actually take all of the data from a given problem and convert it into 
potrzebie units, work the problem in the new system, and then transfer 
the answer back into the original units again. 

Addendum 

My original article contained a few instances of incorrect rounding; as in 
the previous chapters, they have been silently corrected here. I also was 
slow to appreciate the full beauty of 0-origin indexing at the time I wrote 
this exposition, because I still had a residual blind spot: I referred to 
October 1, 1952 as “date 00 cowznofski 1” instead of 00 cowznofski 0. 
Thus all of my newfangled dates were off by one. 

I didn’t learn until later that Chinese people had long ago divided 
each day into 100 equal parts called ke (|0j), before being influenced by 
European missionaries. Nor was I aware that the 18th-century French 
revolutionaries had used a decimal clock, with each day divided into ten 
equal heures, each of which was divided into 100 minutes decimate , each 
of which was divided into 100 secondes decimate — a failed experiment 
that ran from 22 September 1794 to 7 April 1795. (Incidentally, decimal 
clocks of that era said TO’ at the top, not ‘0’.) 

The need for a cowznofski calendar has been mitigated by what 
astronomers call “Julian date,” which is obtained by adding 2434286.5 to 
the cowznofski time. For example, 2271.65498 C.D. is JD 2436558.15498. 
(Note that the UNIX epoch began at 6301.00000 C.D.; hence I propose 
the celebration of a hacker holiday every 100 days on “Tales 1.”) 

In addition to adopting MAD’ s new names for the units of time, 
this article introduced the “axolotl” for what was previously called a 
potcosmo. It also cited “furd” and “egr” units, whose definitions I have 
totally forgotten. 


26 Selected Papers on Fun and Games 

Many of the basic potrzebie units have been acceptable for some time 
to the Google Calculator as well as to Wolfram | Alpha™, so it is natural 
to wonder how many other software systems will adopt them in the fu- 
ture. Although my own system, T)jX, does not accommodate potrzebies 
directly, an excellent approximation (good to within .09 nanometers) is 
obtainable in T^X documents by saying, for example, 

\newdimen\pz \pz=2 . 26334845 17438mm 

and then giving commands like ‘\vskip 2\pz'. (Indeed, I did precisely 
that, just now.) 


Chapter 4 


A MAD Crossword 

[The puzzle on the following two pages was submitted to MAD magazine 
on 28 April 1960 and promptly returned by their Ideas Editor. “The 
author’s first rejected paper.”] 

Notes by the author, July 2009: Flushed with success after my first con- 
tribution to MAD had appeared in print, near the end of my freshman 
year at Case Institute of Technology, I advertised my publication record 
in campaign posters when I ran for a position in the student senate. 

And of course I lost miserably. 

My friends tried to cheer me up. They said, “C’mon, Don, hey, 
write an article that we can understand.” 

I didn’t get another inspiration, however, until a couple years later, 
when I noticed that Alfred E. Neuman’s teeth looked rather like part 
of a crossword puzzle. “Yes, that’s it,” I thought: “If I add a bunch of 
white and black squares in Alfred’s hair, and maybe some more in place 
of his nose, I could design just the sort of puzzle that MAD needs to 
round out its contents.” 

Indeed, crossword puzzles were one of the few things that MAD had 
not yet subjected to its special brand of satire. Will Elder had prepared a 
great spoof on other kinds of puzzles in issue number 19 (January 1955), 
with rebuses, mazes, and visual riddles like connect-the-dots, matching, 
or “What’s wrong with this picture?” A nice take-off on multiple-choice 
questionnaires had also appeared in Jack Davis’s “Pictoquiz” at the end 
of issue 24 (July 1955). But a real crossword puzzle? Not yet. 

Thus it happened that I decided to devote part of spring break, dur- 
ing my senior year, to the design of a Neuman-based crossword puzzle. 

Well, it turned out that my ideas didn’t find favor on Lafayette 
Street in New York; not this time. The editors, displaying possibly un- 
characteristic wisdom, declined my submission, and my potential career 
as a writer of humor in a jugular vein was nipped in the bud. 

But now, after 50 years of writing and with the opportunity to select 
whatever I want for publication, I get the last laugh . . . 


27 


28 Selected Papers on Fun and Games 



Across 

2 Name of kid pictured 
6 This puzzle is a mess 

15 Larval salamander 

16 Bootlegger-shaped country 

18 Opposite of “not over” 

19 Human limb 

20 MAD pencil and paper game 

22 Radioactive material 

23 Sailors’ booze 
25 Ionium 


26 Educational Comics (abbr.) 

28 Munny 

29 n APy*c6a (toct) 

30 Roe ate a new pie 
33 Comedian (singular) 

35 Ammonia 

36 Alcoholics Anonymous 

37 Chemical element 31 

38 Beginning of the English 
alphabet 


A MAD Crossword 29 


40 Opposite of “to” (Russian) 

42 Second sound of man being 
strangled 

43 XXX 

44 Maverick film studio 

45 Opposite of “out” 

46 Pronoun 

47 No good 

48 Conjunction 

49 Blood factor 

Down 

1 Old physiological humor 

2 Author of puzzle 

3 Ugly 

4 Foreign car weighing many 
milligrams 

5 Nickel 

7 First sound of man being 
strangled 

8 Prescription 

9 Unaided performance 

10 Power of 10; or, record book 

11 Former California senator 

12 Past of “eat” 

13 Egyptian god of crossword 
puzzles 

14 Meaningless expression 

17 Pound (abbr.) 

18 Marvin , inventor of 

the wheel 

21 9fnfg oyod'jidi 
24 Opposite of opposite of 
“across” 

27 Typical Maddict 


51 48 across backwards 

52 “What, worry?” 

53 Half a yoyo 

54 Beginning of Greek alphabet 

55 Auf Wiedersehen 

58 Repeated cry 

60 Anterior omentum 

62 Mr. Z’ Beard 

63 Pull out a gun 

64 Most important person 

31 American Automobile 
Association 

32 “ me worry?” 

34 Civil Aeronautics Authority 

35 Sound of ecstasy 
39 Ray’s sidekick 

41 “Bye w ” (Polish, 

to suffer want) 

42 What opponent says when 
playing gin 

43 Train to Yuma (see MAD 

#41) 

44 “What, me ” 

50 Hah 

52 Name of this magazine (no 
fair looking at cover) 

55 Unisymmetrical poly- 
saccharide 

56 Repeated cry 

57 Word used when searching 
for better word 

59 Oxygen 

61 To finish 


30 Selected Papers on Fun and Games 



References 


[1] W. S. Appleton, “Veritas,” in the seal of Harvard University (1885). 

[2] Jack Davis, “Hoohah!” MAD 1,1 (October 1952), 1-8. 

[3] Will Elder, “Are you ever lovely to love?” MAD 1, 24 (July 1955), 5. 

[4] Bob Elliott and Ray Goulding, “House to house,” MAD 1,35 (Oc- 
tober 1957), 36-38. 

[5] A. B. Feldstein, “MAD rejection slip,” MAD 1,38 (March 1958), 5. 

[6] Marginal Marvin, “MAD Y’OX,” MAD 1,54 (April 1960), 2, 3, 4, 5, 
6, 8, 9, 12, 13, 14, 16, 17, 19, 21, 22, 23, 25, 26, 27, 28, 29, 40, 41, 42, 48. 

[7] Roger Price, In One Head and Out the Other (New York: Simon 
and Schuster, 1951), 12-17. 

[8] George Woodbridge (illustrator), “Go west, old format; go east, old 
western,” MAD 1,41 (September 1958), 16-19. 


Chapter 5 


Counterexample to a Statement of Peano 

[A research announcement that was privately circulated in 1965.] 

In 1896, G. Peano [1] claimed that 

1 + 1 = 2 . ( 1 ) 

However, consider the following result: 

Theorem. Under special circumstances, 

1 + 1 = 3. (2) 

Proof. Consider the appearance of John Martin Knuth, who exhibits 
the following characteristics: 


Weight 

8 lb. 10 oz. 

(3912.23419125 grams) 

( 3 ) 

Height 

21.5 inches 

(0.5461 meters) 

( 4 ) 

Voice 

loud 

(60 decibels) 

( 5 ) 

Hair 

dark brown 

(Munsell 5.0Y2.0/11.8) 

(6) 

Q.E.D. □ 





Remarks 

Peano’s error, Eq. (1), has been repeated in the Principia Mathe- 
rnatica [2] and possibly elsewhere. It is not known to what extent the 
theorem above will cause the foundations of mathematics to crumble. 

It is conjectured that the stronger result 

1 + 1 = 4 (7) 

may also be true. Further research on this problem is contemplated, and 
results will be reported in a future paper. 


31 


32 Selected Papers on Fun and Games 

Acknowledgments 

I wish to thank my wife Jill, who worked continuously on this project 
for nine months. We also thank Dr. James Caillouette, who helped to 
deliver the final result. 

This research was not supported by the National Science Foundation. 

References 

[1] Giuseppe Peano, Formulario Mathematico (Rome: Edizioni cremo- 
nese, 1960), 29; Df 2 and prop. 3.3. 

[2] Alfred North Whitehead and Bertrand Russell, Principia Mathe- 
matica 2 (Cambridge University Press, 1910), 83; prop. 110.643. 

California Institute of Technology 
Pasadena, California 

Received July 21, 1965 


Chapter 6 


The Complexity of Songs 


[Originally published in SIGACT News 9,2 (Summer 1977), 17-24.] 

Every day brings new evidence that the concepts of computer science 
are applicable to areas of life that have little or nothing to do with 
computers. The purpose of this survey paper is to demonstrate that im- 
portant aspects of popular songs are best understood in terms of modern 
complexity theory. 

It is known [3] that almost all songs of length n require a text of 
length ~ n. But this puts a considerable space requirement on one’s 
memory, if many songs are to be learned; hence our ancient ancestors 
invented the concept of a refrain [14]. When the song has a refrain, its 
space complexity can be reduced to cn, where c < 1, as shown by the 
following lemma: 

Lemma 1. Let S be a song of length n containing m verses of length V 
and a refrain of length R, where the refrain is to be sung first, last, and 
between adjacent verses. Then the space complexity of S is 

v ht n+0{1) 

for fixed V and R as m — > oo. 

Proof. The length of 5 when sung is 

n — R + (V + R)m, (1) 

while its space complexity is 

c = R + Vm. (2) 

By the Distributive Law and the Commutative Law [4] we have 

c = n — (V + R)m + mV 
= n — Vm — Rm + Vm 
= n — Rm . 


33 


( 3 ) 


34 Selected Papers on Fun and Games 
The lemma follows. □ 

(It is possible to generalize this lemma to the case of verses of dif- 
fering lengths Vi, V 2 , . . . , V TO , provided that the sequence ( V k ) satisfies 
a certain smoothness condition. Details will appear in a future paper.) 

A significant improvement on Lemma 1 was discovered in medieval 
European Jewish communities, where an anonymous composer was able 
to reduce the complexity to 0( v / n). His song, “Ehad Mi Yode’a” or 
“Who Knows One?”, is still traditionally sung near the end of the 
Passover ritual, reportedly in order to keep the children awake [6], It 
consists of a refrain and thirteen verses Vi , . . . , v 13 , where v k is followed 
by Vk-i ■ ■ ■ V 2 V 1 before the refrain is repeated; hence m verses of text lead 
to m 2 / 2 + O(m) verses of singing. A similar song called “Green Grow 
the Rushes O” or “The Dilly Song” is often sung in western Britain at 
Easter time, but it has only ten verses; see [1], Breton, Flemish, German, 
Greek, Medieval Latin, Moravian, and Scottish versions are known. 

The coefficient of s/n was improved further by a Scottish farmer 
named O. MacDonald, whose construction 1 appears in Lemma 2. 

Lemma 2. Given positive integers a and A, there exists a song whose 
complexity is (20 + A + ot)yJn/( 30 + 2A) + 0(1). 

Proof. Consider the following schema [9]: 

Vo = ‘Old MacDonald had a farm, ’ R 4 
R x = ‘Ee-igh, ’ 2 ‘oh! ’ 

R 2 {x) = Vo ‘And on this farm he had some ’ x ‘, ’ R 4 ‘With a ’ 
Ui(x,x') = x ‘, ’ x' ‘ here and a ’ x ‘, ’ x' ‘ there; ’ 

U 2 (x,x') — x ‘here a ’ x' ‘, ’ 

U 3 (x,x') = Ui(x,x') [/ 2 (e, x) U 2 ( L t\x') C/ 2 (‘eve ryw’, x l , ’ x') 

V k = U z {W k ,W' k ) V k —\ for k > 1 (4) 

where 

IVi = ‘chick’, IV 2 = ‘quack’, W 3 = ‘gobble’, 

W 4 — ‘oink’, fV 5 = ‘moo’, IV 6 = ‘hee’, (5) 

and 

W' k — W k for k ^ 6; W' G = ‘haw’. (6) 

1 Actually MacDonald’s priority has been disputed by some scholars; Peter 

Kennedy [8, p. 676] claims that “I Bought Myself a Cock” and similar 
farmyard songs are actually much older. 


The Complexity of Songs 35 


The song of order m is defined by 
5o = e, 

S m = i? 2 (W" ) V m <S m _! for m > 1, (7) 

where 

W" = ‘chicks’, W 2 ' = ‘ducks’, W3 = ‘turkeys’, 

W'l = ‘pigs’, W 5 ' = ‘cows’, Wq = ‘donkeys’. (5) 
The length of S m is 

n = 30 m 2 + 180ra + 4(m/i + 4 b l m ) + (ai H F a m ) (9) 

while the length of the corresponding schema is 

c = 20 m + 211 + (li + • • • + l m ) + ( a i + • • • + flm). ( 10 ) 

Here Ik = | W k \ + |W^| and = | Wj{\, where \x\ denotes the length of 
string x. The result follows at once, if we assume that Ik — A and dk = a 
for all large k. □ 

Note that the coefficient (20 + A + a)/\/30+2A assumes its minimum 
value at 

A = max(l, a — 10) (11) 

when a is fixed. Therefore if MacDonald’s farm animals ultimately have 
long names they should make slightly shorter noises. 

Similar results were achieved by a French Canadian ornithologist, 
who named his song schema “Alouette” [2, 15], and at about the same 
time by a Tyrolean butcher whose schema [5] is popularly called “1st 
das nicht ein Schnitzelbank?” . Several other cumulative songs have been 
collected by Peter Kennedy [ 8 ] , including “The Mallard” with seventeen 
verses and “The Barley Mow” with eighteen. More recent compositions, 
like “There’s a Hole in the Bottom of the Sea” and “I Know an Old 
Lady Who Swallowed a Fly,” unfortunately have comparatively large 
coefficients. 

A fundamental improvement was claimed in England in 1824, when 
the true love of U. Jack gave to him a total of 12 ladies dancing, 22 lords 
a-leaping, 30 drummers drumming, 36 pipers piping, 40 maids a-milking, 
42 swans a-swimming, 42 geese a-laying, 40 golden rings, 36 collie birds, 
30 french hens, 22 turtle doves, and 12 partridges in pear trees during 
the twelve days of Christmas [11, 12, 13]. This amounted to m 3 / 6 + 
m 2 /2 + m/3 gifts in m days, when summed, so the complexity appeared 
to be 0 (y/n)- however, another researcher soon pointed out [ 10 ] that his 
computation was based on n gifts rather than on n units of singing. The 
correct complexity of order y/n/ log n was finally established (see [7]). 


36 Selected Papers on Fun and Games 

Thus the partridge in the pear tree gave an improvement of only 
1/ \/Iog n ; but the importance of this discovery should not be underesti- 
mated, since it showed that the rr 5 barrier could be broken. The next big 
breakthrough was in fact obtained by generalizing the partridge schema 
in a remarkably simple way. It was J. W. Blatz of Milwaukee, Wiscon- 
sin, who first discovered a class of songs known as “m Bottles of Beer 
on the Wall”; her elegant construction 2 appears in the following proof 
of the first major result in the theory. 

Theorem 1. There exist songs of complexity O(logn). 

Proof. Consider the schema 

V k =T k BW 7 
T k B V 

‘If one of those bottles should happen to fall,’ 

Tk - 1 B W‘.’ (12) 


where 


B — ‘ bottles of beer’, 

W = ‘ on the wall’, (13) 

and where T k is a translation of the integer k into English. Only 0(m ) 
space is required to define T k for all k < 10 m , since we can let 

T q . wm+r = T q ‘ times 10 to the ’ T m ‘ plus ’ T r (14) 

for 1 < q < 9 and 0 < r < 10 m_1 . 

Therefore the songs S k defined by 

So = e, S k = V k S k -i for k > 1 (15) 

have length n x /clogfc, but the schema that defines them has length 
O(logfc); the result follows. □ 


2 Again Kennedy [8] claims priority for the English, in this case because of 
the song “I’ll drink m if you’ll drink m+ 1.” However, the English start at 
m = 1 and get no higher than m = 9, possibly because they actually drink 
the beer instead of allowing the bottles to fall. 


The Complexity of Songs 37 

Theorem 1 was the best result known until recently, 3 perhaps be- 
cause it satisfied all practical requirements for song generation with 
limited memory space. In fact, 99 bottles of beer usually seemed to 
be more than sufficient in most cases. 

However, the advent of modern drugs has led to demands for still less 
memory, and the ultimate improvement of Theorem 1 has consequently 
just been announced: 

Theorem 2 . There exist arbitrarily long songs of complexity 0(1). 

Proof (due to KC and the Sunshine Band). Consider the songs S*, de- 
fined by (15), but with 

Vfc = ‘That’s the way, ’ U ‘(I like it), ’ U 
U = ‘uh huh, ’ 2 (16) 


for all k. □ 

It remains an open problem to study the complexity of nondeter- 
ministic songs. 

Acknowledgment 

I wish to thank J. M. Knuth and J. S. Knuth for suggesting the topic of 
this paper, on a trip to Pinnacles National Monument in October 1976. 

The research reported here was supported in part by the National Institute of Wealth 
under grant $262,144. 

References 

[1] S. Baring-Gould, H. Fleetwood Sheppard, and F. W. Bussell, edited 
by Cecil J. Sharp, Songs of the West: Folk Songs of Devon & Corn- 
wall (London: Methuen, 1905), 160-161. 

[2] Oscar Brand, Singing Holidays: The Calendar in Folk Song (New 
York: Alfred Knopf, 1957), 68-69. 

[3] Gregory J. Chaitin, “On the length of programs for computing fi- 
nite binary sequences: Statistical considerations,” Journal of the 
Association for Computing Machinery 16 (1969), 145-159. 

[4] G. Chrystal, Algebra, an Elementary Textbook for the Higher 
Classes of Secondary Schools and for Colleges (Edinburgh: Adam 
and Charles Black, 1886), Chapter 1. 

3 The chief rival for this honor was “This old man, he played m, he played 
knick-knack . . . ” . 


38 Selected Papers on Fun and Games 

[5] Anton Dorrer, Tiroler Fasnacht innerhalb der alpenlandischen Win- 
ter- und Vorfriihlingsbrauche (Vienna: Osterreichischer Bundes- 
verlag flir Unterricht, Wissenschaft und Kunst, 1949), 480 pages. 

[6] Encyclopaedia Judaica 6 (New York: Macmillan, 1971), 503; The 
Jewish Encyclopedia (New York: Funk and Wagnalls, 1903), articles 
on Ehad Mi Yode’a. 

[7] U. Jack, “Logarithmic growth of verses,” Acta Perdix 15 (1826), 
1-65535. 

[8] Peter Kennedy, editor, Folksongs of Britain and Ireland (New York: 
Schirmer, 1975), 824 pages. 

[9] Norman Lloyd, The New Golden Song Book (New York: Golden 
Press, 1955), 20-21. 

[10] N. Picker, “Once sehores brincando al mismo tiempo,” Acta Perdix 
12 (1825), 1009. 

[11] ben shahn, a partridge in a pear tree (new york: the museum of 
modern art, 1949), 28 pages (unnumbered). 

[12] Cecil J. Sharp, editor, One Hundred English Folksongs (Boston: 
Oliver Ditson, 1916), xlii, 224-225 (song number 96). 

[13] Christopher J. Shaw, “That old favorite, Apiapt / a Christmastime 
algorithm,” with illustrations by Gene Holtan, Datamation 10, 12 
(December 1964), 48-49. Reprinted in Faith, Hope and Parity , 
edited by Jack Moshman (Washington, D.C.: Thompson, 1966), 
37, 48-51. 

[14] Gustav Thurau, Beitrage zur Geschichte und Charakteristik des 
Refrains in der franzbsischen Chanson (Weimar: Felber, 1899), 
47 pages. 

[15] Marcel Vigneras, editor, Chansons de France (Boston: D. C. Heath, 
1941), 52 pages. 

Addendum 

I wrote this paper for the April 1977 issue of SIGACT News, not know- 
ing that no such issue would exist; the editor had meanwhile decided 
that the successor to the January-March 1977 issue should be dated 
“Summer 1977” in order to correspond better with the time when peo- 
ple actually received their copies. My original goal was finally achieved 
when the paper was reprinted in the April 1984 issue of ACM’s Com- 
munications. [More formally, the reference is: Donald E. Knuth, “The 


The Complexity of Songs 39 

complexity of songs,” Communications of the ACM 27 (April 1984), 
344-346; errata (June 1984), 593.] 

Guy Steele Jr. wrote me in June 1977 to mention tradeoffs between 
time complexity and space complexity. He observed that successive 
verses of Jacques Brel’s song Carousel are sung with increasing tempo. 
“This latter property is of importance to songwriters: While refrains 
increase the efficiency of writing the song, the nonconstant tempo de- 
creases it, given that royalties on recordings are based on song-minutes 
(with some per-song quantization) under both the old and new copy- 
right laws.” 

Guy later published “The TELNET song (‘Control-Uparrow Q’),” 
Communications of the ACM 27 (April 1984), 347-348, a brilliant com- 
position whose complexity is O (log log n). 

Extensions of the theory have also been developed by Charles Crow- 
ley, “A finite state machine for western swing,” SIGPLAN Notices 16 , 4 
(April 1981), 33-35; and by Kurt Eisemann, “Further results on the com- 
plexity of songs,” Communications of the ACM 28 (1985), 235. 





Chapter 7 


TPK in INTERCAL 


[Based on an unpublished manuscript written in 2003.] 


Sooner or later every “real” programmer discovers INTERCAL, the mind- 
boggling Compiler Language With No Pronounceable Acronym [7]. The 
successful completion of a nontrivial INTERCAL program is, to a pro- 
grammer, a thrill that’s rather like the successful ascent of Mount Ever- 
est is to a climber. 

On the other hand, one should be aware of the formidable dan- 
gers that lurk therein, because INTERCAL is full of “twisted technical 
yuks and an inexorable descent into brain-sucking obsession ... for . . . 
iibergeeks .... Expressions that look like line noise. Control constructs 
that will make you gasp, make you laugh, and possibly make you hurl. 
. . . INTERCAL. Designed very early one May morning in 1972 by two 
hackers who are still trying to live it down.” [4] 

Luis Trabb Pardo and I once wrote a paper [3] in which we discussed 
the details of about two dozen programming languages that were devel- 
oped before 1958. We introduced a simple procedure called the “TPK 
algorithm,” and gave the flavor of each language by expressing TPK in 
each particular style. Since then, TPK has been programmed for just 
about every other language [6] — except one. The purpose of this note is 
to remove that much-needed gap from the computer-language literature. 

The TPK algorithm inputs eleven numbers a 0 , a 1} . . . , a w \ then it 
outputs a sequence of eleven pairs (10, b 10 ), (9, 6 9 ), . . . , (0, b 0 ), where 


f f(a t ), if f(a t ) < 400; 
I 999, if /(a*) > 400; 


f(x) = tJ\x\ + 5a: 3 . 


This simple task is obviously not much of a challenge, in any decent com- 
puter language. But Don Woods and Jimbo Lyon intended INTERCAL 
to have nothing at all in common with any of the languages they’d ever 
seen before; so they left out little things like addition, multiplication, 


41 


42 Selected Papers on Fun and Games 

conditional statements, loops, etc. “INTERCAL’s main advantage over 
other programming languages is its strict simplicity. It has few capa- 
bilities, and thus there are few restrictions to be kept in mind. Since it 
is an exceedingly easy language to learn, one might expect it would be 
a good language for initiating novice programmers. Perhaps surprising, 
then, is the fact that it would be more likely to initiate a novice into a 
search for another line of work.” [7] 

Although INTERCAL has no intrinsic arithmetic operations, it does 
perform input and output, which it calls “writing in” and “reading out.” 
And it does work with sequences of Os and Is that might be regarded 
as numbers, so we may as well say that its bit strings are numbers. But 
it has only two ways to combine two numbers, namely mingling and 
selecting. If x = ( . . . and y = ( • • • 2 / 22 / 12 / 0)2 are bit strings that 

represent binary numbers, they can be mingled to form 

xfy = (... x 2 y 2 Xiyix 0 yo) 2 . 

(Nowadays this operation is more commonly called a “perfect shuffle” 
or the “zipper function,” x\y, see Eq. 7.1.3-(76) in [1].) The selection 
operation x ~ y is more difficult to describe via formulas, but it too is 
intuitively simple: If exactly s of the bits of y are equal to 1, namely 
bits yj i for s > i > 0 where j s -\ >•■•> j\> jo, then 

x ~ y — ( x js-i ■ ■ ■ x ji x j<>)2- 

Of course x ~ 0 = 0. Notice that y ~ y — 2 s — 1. 

All numbers in INTERCAL are either short (16 bits) or long (32 bits), 
and they’re always nonnegative. Thus short numbers are always integers 
that are less than 65536; long numbers are always integers that are less 
than 4294967296. INTERCAL allows you to specify any short number 
directly, by providing 65536 constants written respectively as #0, #1, 

. . . , #65535. It also allows you to use up to 65535 short variables, called 
respectively .1, .2, . . . , .65535, which can take on any short number as 
a value; similarly it permits up to 65535 long variables, called :1, :2, 

. . . , : 65535. There are 65535 short array variables ( ,1 through ,65535) and 
65535 long array variables (;1 through ; 65535 ) too. Lotsa variables. 

We’re ready now to look at a short (and very trivial) example of 
INTERCAL code. Line 01 of the program excerpt in Table 1 says that 
,16080 is an array with 15 elements. The remaining lines set the last 
seven of those elements respectively to (0,6,41,136,322,999,999,999). 
Notice that each statement in Table 1 begins either with PLEASE, DO, or 
PLEASE DO. These three possibilities are interchangeable, except that the 


TPK in INTERCAL 43 

Table 1. Initializing part of a small array of short numbers 


01 

PLEASE DO 

,16080 <- #15 

02 

DO 

,16080 

SUB 

#8 <- #0 

03 

DO 

,16080 

SUB 

#9 <- #6 

04 

DO 

,16080 

SUB 

#10 <- #41 

05 

PLEASE ,16080 

SUB #11 <- #136 

06 

DO 

,16080 

SUB 

#12 <- #322 

07 

DO 

,16080 

SUB 

#13 <- #999 

08 

PLEASE DO 

,16080 SUB #14 <- ,16080 SUB #13 

09 

DO 

,16080 

SUB 

#15 <- #29 i #27 


ratio of polite statements must be between 1/5 and 1/3 in any program 
that has more than two statements.* 

Besides the binary operators x / y and x ~ y, INTERCAL has 
three unary operators that transform one number into another, namely 
and (Si), or (V), and xor (V). When applied to a number x, a unary 
operator yields the result that’s obtained by first (i) rotating x cycli- 
cally one place to the right, yielding y, then (ii) applying the speci- 
fied bitwise operation to x and y. For example, suppose x equals 
2009, namely (...011111011001)2. Then the and operation will yield 
( . . . 001111001000) 2 . The xor operation will yield (1000010000110101) 2 
if x is short, but (10000000000000000000010000110101) 2 if x is long. 

Let’s look now at some algebraic expressions that use several opera- 
tions at once. Subexpressions that are to be evaluated first are grouped 
by enclosing them within a pair of either single quotes or double quotes: 

Table 2. One way to use the short numbers installed by Table 1 


10 

PLEASE DO 

:2 <- : r 1 #65534i<#65532 

11 

DO .1 <- 

1 : 2~ : 2 1 ~#1 

12 

DO .1 <- 

!l«f.l'^#4 

13 

DO READ OUT ,16080 SUB "T:r#7'i 


Suppose variable :1 contains the value x. Statement 10 sets :2 to [ar/8j , 
by shifting x right three places, because ' #65534f!#65532 ' is the 32-bit con- 
stant (1 . . . 11000) 2 . The statement in line 11 then sets . 1 to 0 if : 2 is 
zero, otherwise to 1; in other words, it sets .1 to 1 if and only if x > 8. 
Statement 12 uses ! as a convenient abbreviation for the two symbols 1 . 
(which would otherwise make the expression look more complex); you 
can check that .1 is now 16 if x < 8, 26 otherwise. Finally, the pile of 
hair following SUB in line 13 illustrates the fact that the unary operator 
symbols of INTERCAL are always placed one character to the right of 


* Please do remember that Don Woods wrote Adventure (Chapter 27) in 1977. 


44 Selected Papers on Fun and Games 

where their operands actually begin: The value of .VI is the or of .1 
(which of course is either 24 or 31); and the other V computes the or of 
the stuff in double quotes, namely 1 :1~#77.V1. (Similarly, #&11 equals #1, 
etc.) Thus it turns out that the subscript evaluates to x + 8 if x < 8, 
while it evaluates to 15 whenever x > 8. 

Line 13 therefore outputs the respective values 0, 6, 41, 136, 322, 
999, 999, . . . , if x is respectively equal to 0, 1, 2, 3, 4, 5, 6, 7, ... . 

Wow! What a coincidence! Those are exactly the values bi that the 
TPK algorithm is supposed to output, when ai — x\ 

Indeed, the TPK algorithm is a no-brainer on a machine that deals 
only with nonnegative integers, because bi can take at most six different 
values. I should have realized that fact when discussing Bohm’s compiler 
of 1951 in [3], rather than laboriously writing a subroutine to calculate 
square roots that would never contribute to the program output. 

But hmmm: I really want to illustrate INTERCAL, most of whose 
features have yet to be mentioned. In the words of Randy Bachman and 
Ronald Reagan, “You ain’t seen nothin’ yet.” Let us therefore change 
the problem and work with fixed-point, scaled numbers, represented as 
integers within an INTERCAL program: Let’s assume that the values a t 
and bi are nonnegative real numbers with at most six digits to the right 
of the decimal point. In other words, we’ll suppose that 10 6 ai and 10 6 6,; 
are nonnegative integers. The revised problem will give us a chance to 
stop, think, learn, and smile. 

I don’t have space enough here to provide a full INTERCAL tu- 
torial. Instead, I’m exhibiting the complete TPK program in Table 3, 
which extends over the next several pages; and I shall explain its general 
principles in the remainder of these notes. 

All of INTERCAL ’s idiosyncrasies are detailed in the reference man- 
ual [7], which is available online. If you truly are one of my soul-mates, 
programmingwise — which you probably are, if you’ve read this far — 
I believe you’ll enjoy unlocking the manifold mysteries of this puzzling 
code, by consulting [7] whenever the program uses a feature that’s not 
fully explained in the hints that follow Table 3. 

TABLE 3. My favorite illiterate program 

001 PLEASE ABSTAIN FROM (29733) 

002 (29733) DON KNUTH'S IMPLEMENTATION OF TPK IN INTERCAL 

003 (C) MARCH 2003, NOVEMBER 2010 

004 REFERENCE — THE EARLY HISTORY OF PROGRAMMING 

005 LANGUAGES, BY D E KNUTH AND L TRABB PARDO 

006 


TPK in INTERCAL 45 


00 1 NOTA BENE: THE INPUT AND OUTPUT DATA ARE SCALED 

008 DECIMAL NUMBERS WITH SIX DIGITS TO THE RIGHT OF 

009 THE DECIMAL POINT; THUS AN INPUT OF 

010 THREE ONE FOUR ONE FIVE NINE THREE 

011 DENOTES 3.141593, AND THAT VALUE WOULD BE OUTPUT AS 

012 

013 MMMCXLMDXCI I I 

014 

015 PLEASE NOTICE THAT VARIABLE NAMES AND SUBROUTINE NAMES USE 

016 THE 5-BIT TELEPRINTER CODE IN LETTER-SHIFT MODE, NAMELY 
Oil / E @ A : S I U 1/4 DRJNFCKTZLWHYPQOBG"MXV$ 

018 (WHICH ALAN TURING ADVISED EVERY PROGRAMMER TO LEARN) 

019 

020 PLEASE (6534) NEXT 

021 DO ; 29 <- #2 

022 DO ;3 <- #11 BY #2 

023 PLEASE DO .6 <- #0 

024 DO (1) NEXT 

025 (1) PLEASE DO FORGET #1 

026 DO WRITE IN : 1 

027 DO (22919) NEXT 

028 PLEASE .1 <- .6 

029 PLEASE DO (1020) NEXT 

030 DO .11 <- .1 

031 DO ;3 SUB .11 #1 <- ;1 SUB #1 

032 DO ;3 SUB .11 #2 <- ;1 SUB #2 

033 DO .1 <- #10 

034 DO (29904) NEXT 

035 DO (1) NEXT 

036 DO REINSTATE NEXTING 

031 PLEASE DO (2) NEXT 

038 (2) DO FORGET #1 

039 DO .984 <- #0 

040 PLEASE .1 <- .6 

041 PLEASE DO (1020) NEXT 

042 DO .11 <- .1 

043 DO ;29 SUB #1 <- ;3 SUB .11 #1 

044 DO ; 29 SUB #2 <- ;3 SUB .11 #2 

045 PLEASE DO (13) NEXT 

046 DO (15478) NEXT 

047 DO (15320) NEXT 

048 DO :2 <- #6528^*32544 

049 PLEASE DO (23438) NEXT 

050 DO :1 <- #31640^*20792 

051 DO REMEMBER :1 

052 DO READ OUT .6 + :1 

053 DO .1 <- #0 

054 DO ABSTAIN FROM (711) 

055 PLEASE DO (29904) NEXT 


46 Selected Papers on Fun and Games 


056 DO (2) NEXT 

057 DO GIVE UP 

058 

059 PLEASE USE THE FOLLOWING FUNCTION, WHICH SETS ;1 <- F(;X) 

060 WHERE ;29 AND ;1 ARE EXTENDED FIXED-POINT NUMBERS 

061 (THAT IS, THEY ARE VECTORS WITH TWO COMPONENTS, 

062 #1=INTEGER PART, #2=FRACTI0N PART) 

063 (13) DO STASH ;2 

064 DO ;1 SUB #1 <- ;29 SUB #1 

065 DO ;1 SUB #2 <- ;29 SUB #2 

066 PLEASE STASH ; 1 

067 PLEASE DO ;2 SUB #1 <- ;29 SUB #1 

068 DO ;2 SUB #2 <- ;29 SUB #2 

069 DO (30300) NEXT 

070 DO (30300) NEXT 

071 DO ;2 SUB #1 <- #5 

072 DO ;2 SUB #2 <- #0 

073 PLEASE DO (30300) NEXT 

074 PLEASE DO ;2 SUB #1 <- ;1 SUB #1 

075 DO ;2 SUB #2 <- ;1 SUB #2 

076 PLEASE RETRIEVE ; 1 

077 DO (30499) NEXT 

078 PLEASE DO (30218) NEXT 

079 DO (29987) NEXT 

080 DO RETRIEVE ;2 

081 PLEASE RESUME #1 

082 

083 DO NOTHING BUT BASIC SUBROUTINES FROM HERE ON 

084 

085 FIRST THERE ARE ROUTINES FOR EXTENDED ARITHMETIC 

086 (DOUBLE-DOUBLE PRECISION) , WHICH CONSISTS OF 

087 TWO 32-BIT NUMBERS WITH A BINARY POINT BETWEEN THEM 

088 

089 TO GET STARTED, DO (INI) FIRST; IT DEFINES BASIC ARRAYS 

090 (6534) DO ;1 <- #3 

091 DO ;2 <- #2 

092 PLEASE RESUME #1 

093 

094 DON'T FORGET TO TEST FOR OVERFLOW AFTER A SERIES OF 

095 EXTENDED ARITHMETIC OPERATIONS: 

096 THE (OVC) ROUTINE SETS :1 TO THE MAX VALUE IF ,0V IS 1 

097 ... SO YOU’D BETTER SET ,0V TO 0 PERIODICALLY 


098 (15320) PLEASE DO (2000) NEXT 

099 DO :1 <- #65535(!#65535 

100 PLEASE RESUME #1 

101 (2000) PLEASE DO (2001) NEXT 

102 PLEASE RESUME #2 

103 (2001) DO RESUME ' V. 984><#1 ’ ~#3 

104 


TPK in INTERCAL 


47 


105 

DOING (ADY) NEXT SETS ;1 <- ;l+;2+.C'2 AND .C <- CARRY+1 

106 

DOING (ADZ) NEXT SETS ;1 <- ;l+;2 AND .C <- CARRY+1 


107 

(17699) PLEASE .14 <- #1 


108 

(21795) DO STASH :1 + :2 + :3 + :4 


109 

DO : 1 <- ;1 SUB #2 


110 

PLEASE DO :2 <- . 14"#2 


111 

PLEASE DO (1509) NEXT 


112 

DO .14 <- :4'#2 


113 

DO :1 <- :3 


114 

PLEASE DO :2 <- ; 2 SUB #2 


115 

DO (1509) NEXT 


116 

DO ;1 SUB #2 <- :3 


117 

DO : 1 <- ;1 SUB #1 


118 

DO :2 <- "V-IA*!' :4"#2' n ~#l 


119 

DO (1509) NEXT 


120 

DO .14 <- :4 


121 

DO :1 <- :3 


122 

DO :2 <- ;2 SUB #1 


123 

DO (1509) NEXT 


124 

DO ;1 SUB #1 <- :3 


125 

DO .14 <- 1 V : 4^ . 14 1 ~#6 


126 

PLEASE RETRIEVE :1 + :2 + :3 + :4 


127 

PLEASE RESUME #1 


128 



129 

DOING (ADX) NEXT SETS ;1 <- ;l+;2 AND TRACKS OVERFLOW 


130 

DOING (ABX) NEXT SETS ;1 <- ABS(;1) 


131 

(29987) PLEASE STASH .14 


132 

DO (17699) NEXT 


133 

DO .984 <- "V.984^!14"#2'"~#l 


134 

PLEASE RETRIEVE .14 


135 

(30499) DO RESUME #1 


136 



137 

DOING (SUX) NEXT SETS ;1 <- ;l-;2 AND TRACKS OVERFLOW 


138 

(29925) PLEASE STASH ;2 + .14 


139 

DO ;2 SUB #1 <- MI V"';2 SUB #1"""#65535(!#0" 7#65535" _l 

"#0^#65535" 7 

140 

"V";2 SUB #l"'"#0(i#65535 , "(!#65535"' 1 

"#0k!#65535" ' 

141 

DO ;2 SUB #2 <- '"V 1 "^ SUB #2"~"#65535»'#0" 1 ^#65535" _l 


142 

1 "V " ; 2 SUB #2" " "#0«d#65535" 1 ^#65535" " 

"#0k!#65535"' 

143 

DO .14 <- #2 


144 

DO (21795) NEXT 


145 

PLEASE DO .984 <- "V . 984k! ! 14~#1 1 "~#1 


146 

PLEASE RETRIEVE ;2 + .14 


147 

DO RESUME #1 


148 



149 

DOING (SHY) NEXT SETS ;2 <- :3 * 2*16 AND CLOBBERS :3 


150 

(22149) DO ;2 SUB #1 <- :3 ' ' #65280<!#65280 1 


151 

DO :3 <- 1 " ' :3"#436907#0"~"#65535|!#1" 1 i 


152 

' :3~#21845'«!#0"~"#65535k!#1" ' 


153 

PLEASE :3 <- " :3~ '#511((!#1 t " : 3~ 1 #1<!#511 ' " 



48 Selected Papers on Fun and Games 


154 PLEASE :3 <- ":3"'#1023f!#3'" i " : 3" ' #3«'#1023 1 " 

155 DO ; 2 SUB #2 <- 3' '#4095^15 1,1 i 3‘' #15^4095 

156 PLEASE RESUME #1 

157 

158 DOING (MLY) NEXT SETS ;1 <- :1 * :2 / 2"32 

159 (22108) PLEASE STASH :1 + :2 + :3 + ;2 + .14 

160 DO :1 <- :1 * #65535 

161 DO :2 <- :2 * #65535 

162 DO (1540) NEXT 

163 DO ;1 SUB #2 <- :3 

164 DO ;1 SUB #1 <- #0 

165 PLEASE RETRIEVE : 1 

166 PLEASE STASH :1 

167 DO : 1 <- : 1 1 #65280)il#65280 ' 

168 DO (1540) NEXT 

169 DO (22149) NEXT 

170 DO (17699) NEXT 

171 PLEASE RETRIEVE :1 + :2 

172 PLEASE STASH :1 + :2 

173 DO : 1 <- : 1 _ #65535 

174 DO :2 <- :2 ' , #65280(!#65280 l 

175 DO (1540) NEXT 

176 DO (22149) NEXT 

177 DO (17699) NEXT 

178 PLEASE RETRIEVE :1 

179 PLEASE STASH :1 

180 DO :1 <- :1 '#65280^*65280' 

181 DO (1540) NEXT 

182 DO ;2 SUB #2 <- #0 

183 DO ;2 SUB #1 <- :3 

184 DO (17699) NEXT 

185 PLEASE RETRIEVE :1 + :2 + :3 + ;2 + .14 

186 PLEASE RESUME #1 

187 

188 DOING (MLZ) NEXT SETS ;1 <- ;1 + (:1 * :2 / 2*32), TRACKING OVERFLOW 

189 (18012) PLEASE STASH ;1 + ;2 

190 DO (22108) NEXT 

191 PLEASE ;2 SUB #1 <- ;1 SUB #1 

192 PLEASE ;2 SUB #2 <- ;1 SUB #2 

193 PLEASE RETRIEVE ;1 

194 DO (29987) NEXT 

195 PLEASE RETRIEVE ;2 

196 PLEASE RESUME #1 

197 

198 DOING (MLX) NEXT SETS ;1 <- ;1*;2 AND TRACKS OVERFLOW 

199 (30300) PLEASE STASH :1 + :2 + :3 + :4 + ;1 + ;2 

200 DO :1 <- ;1 SUB #2 

201 DO :2 <- ;2 SUB #2 

202 DO (22108) NEXT 


TPK in INTERCAL 49 


203 

DO 

1 <- ;1 SUB #1 

204 

DO 

2 <- ' ; 1 SUB #2 ’ " '#32768<!#0' 

205 

DO (1500) NEXT 

206 

PLEASE RETRIEVE ;1 

207 

DO 

4 <- ; 1 SUB #2 

208 

DO 

1 <- ;1 SUB #1 

209 

DO 

2 <- ;2 SUB #1 

210 

DO (22108) NEXT 

211 

PLEASE DO .984 <- "V.984f!' " ' ;1 SUB #1 

212 

DO 

1 SUB #1 <- ;1 SUB #2 

213 

DO 

1 SUB #2 <- :3 

214 

DO 

2 <- ;2 SUB #2 

215 

DO (18012) NEXT 

216 

DO 

1 <- :4 

217 

DO 

2 <- ;2 SUB #1 

218 

DO (18012) NEXT 

219 

PLEASE RETRIEVE :1 + :2 + :3 + :4 + ;2 

220 

PLEASE RESUME #1 

221 



222 

DOING (RTX) NEXT SETS ;1 <- SQRT(;1) 


223 (30218) PLEASE STASH .6 + ;2 + ;3 + ;4 + :1 + :2 + .1 + .2 + .3 + .14 + .984 


224 

DO 

4 <- #2 


225 

DO 

3 <- #2 


226 

DO 

6 <- #1 


227 

DO 

3 SUB #1 <- #0 


228 

DO 

3 SUB #2 <- #0 


229 

DO 

4 SUB #1 <- #65535<!#65535 

230 

DO 

4 SUB #2 <- ;4 SUB 

#1 

231 

DO 

1 <- ;1 SUB #1 


232 

DO 

2 <- ;1 SUB #2 


233 

PLEASE (2003) NEXT 


234 (2002) 

DO 

2 SUB #1 <- ;1 SUB 

#1 

235 

DO 

2 SUB #2 <- ; 1 SUB 

#2 

236 

DO (17699) NEXT 


237 

DO 

2 SUB #1 <- ;1 SUB 

#1 

238 

DO 

2 SUB #2 <- ;1 SUB 

#2 

239 

DO (17699) NEXT 


240 

PLEASE DO ;2 SUB #1 <- 

#0 

241 

PLEASE DO ;2 SUB #2 <- 

.2 

242 

DO (17699) NEXT 


243 

PLEASE DO ;2 SUB #2 <- 

.3 

244 

DO (29925) NEXT 


245 

PLEASE DO ;3 SUB #1 <- 

;1 SUB 

246 

PLEASE DO ;3 SUB #2 <- 

;1 SUB 

247 

PLEASE DO ;1 SUB #1 <- 

;4 SUB 

248 

PLEASE DO ;1 SUB #2 <- 

;4 SUB 

249 

DO 

2 SUB #1 <- ;1 SUB 

#1 

250 

DO 

2 SUB #2 <- ;1 SUB 

#2 

251 

DO 

(17699) NEXT 



Hr 

50 

Selected Papers on Fun and Gaines 

252 


DO ;2 SUB #1 <- #0 

253 


PLEASE DO ;2 SUB #2 <- "V#l«( . 3" ~#1 

254 


DO (17699) NEXT 

255 


PLEASE DO ;4 SUB #1 <- ;1 SUB #1 

256 


PLEASE DO ;4 SUB #2 <- ;1 SUB #2 

257 


DO .1 <- ":1 ‘ 1 #21845^#0 1 " t 

258 


'"V : 1""#10922^#1" 1 t '"V : 1~#1 1 jf 1 : 2 _ "#32768jf#0" 1 "~#1 ' " '#21845' 

259 


DO .2 <- ":1 ‘ '#0<!#21845'" i 

260 


l "V l :r ,l #0f!#10923" 1 t MI V : 1~#1 ' ' :2'"#0»!#32768'""'#1"' '#21845' 

261 


DO :1 <- .1 i .2 

262 


DO .1 <- ":2 ' , #21845(!#0" 1 t 

263 


:2'"#10922<‘#1" ' l #65534" ' #21845' 

264 


DO .2 <- ":2 ‘ '#0f!#21845"' t 

265 


' :2~"#0#;#10923" ' t #65534" ' #21845' 

266 


DO :2 <- .1 t .2 

267 

(2003) 

DO .2 <- :1 ' ' #32768^#32768 ' 

268 


DO ;1 SUB #1 <- ;3 SUB #1 

269 


DO ;1 SUB #2 <- ;3 SUB #2 

270 


DO ;2 SUB #1 <- ;4 SUB #1 

271 


DO ;2 SUB #2 <- ;4 SUB #2 

272 


DO .14 <- #2 

273 


DO (21795) NEXT 

274 


DO .3 <- ' " ; 1 SUB #1 ' " ' ; 1 SUB #1'"'#1' t 

275 


; 1 SUB #2 1 ’ ' ; 1 SUB #2'"'#1' " i .2' ' #15 

276 


DO .3 <- T'!3".3'~#l" i .14' ' #2 

277 


PLEASE DO (2004) NEXT 

278 


DO ;1 SUB #1 <- ;3 SUB #1 

279 


DO ;1 SUB #2 <- ;3 SUB #2 

280 


DO (2005) NEXT 

281 

(2004) 

DO (2006) NEXT 

282 

(2005) 

PLEASE FORGET #1 

283 


PLEASE DO .1 <- #49 

284 


DO (29904) NEXT 

285 


DO (2002) NEXT 

286 


PLEASE REINSTATE NEXTING 

287 


DO ;2 SUB #1 <- ;4 SUB #1 

288 


DO ;2 SUB #2 <- ;4 SUB #2 

289 


DO ;1 SUB #1 <- #0 

290 


DO ;1 SUB #2 <- #0 

291 


DO (29925) NEXT 

292 


DO ;2 SUB #1 <- #0 

293 


DO ;2 SUB #2 <- "V.3«!#l""#l 

294 


DO (29925) NEXT 

295 


PLEASE RETRIEVE .6 + ;2 + ;3 + ;4 + :1 + :2 + .1 + .2 + .3 + .14 + .984 

296 


PLEASE RESUME #50 

297 

(2006) 

PLEASE RESUME "V.3)(!#2"~#3 

298 



299 


DOING (UNP) NEXT SETS ;1 <- :1 / 1000000 

300 


(WHICH IS ESSENTIALLY DECIMAL TO BINARY CONVERSION) 


TPK in INTERCAL 51 


301 

(22919) PLEASE STASH :1 + :2 + :3 + :4 + .3 

302 


DO :2 <- #784 i #904 

303 


PLEASE DO (1550) NEXT 

304 


PLEASE DO ;1 SUB #1 <- :3 

305 


DO : 1 <- :3 

306 


DO (1540) NEXT 

307 


DO RETRIEVE :1 

308 


PLEASE STASH :1 

309 


DO :2 <- :3 

310 


PLEASE DO (1510) NEXT 

311 


PLEASE DO :4 <- #32768 t #0 

312 


DO ;2 SUB #1 <- #0 

313 


DO ;2 SUB #2 <- #0 

314 


DO :1 <- :3 

315 


PLEASE DO (2008) NEXT 

316 

(2007) 

DON'T RESUME #1 

317 


DO : 1 <- ;1 SUB #2 

318 


DO .3 <- :4"#1 

319 


DO (2009) NEXT 

320 


DO :4 <- : 4~ 1 #65535^*65534 ' 

321 

(2008) 

DO :2 <- :1 

322 


PLEASE DO (1500) NEXT 

323 


DO : 1 <- :3 

324 


DO ;1 SUB #2 <- :3 

325 


DO :2 <- #48576 

326 


PLEASE DO (1500) NEXT 

327 


DO .3 <- :3~'#0^#1024' 

328 


DO ;1 SUB M, V.3<!#2"~#6' <- ' :3""#65535f!#0" 1 t 

329 


1 "ft : 3~ 1 #0^#65535 1 "^#64511 ' " - "m#65535"' 

330 


DO :2 <- ;2 SUB 1 "V. 3#!#1"~#3 ' 

331 


DO :2 <- " ' V" : 2" ' #65535itt0 "V" : 4" ' #65535<f#0 ' " 1 * '#0<!#65535 

332 


" 1 V" : 2~ 1 #0i(#65535 1 "if" :4” 1 #0^#65535 1 " 1 * '#0|i#65535 

333 


PLEASE DO ;2 SUB 1 "V . 3«(#1" ’#3 1 <- :2 

334 


PLEASE DO (2007) NEXT 

335 


DO ;1 SUB #2 <- ;2 SUB #2 

336 


PLEASE ABSTAIN FROM (2007) 

337 


PLEASE RETRIEVE :1 + :2 + :3 + :4 + .3 

338 


PLEASE RESUME #34 

339 

(2009) 

PLEASE DO (2006) NEXT 

340 


DO REINSTATE (2007) 

341 


PLEASE FORGET #2 

342 


DO (2008) NEXT 

343 



344 


DOING (PAK) NEXT SETS :1 <- 1000000 * ;1, TRACKING OVERFLOW 

345 


(WHICH IS ESSENTIALLY BINARY TO DECIMAL CONVERSION) 

346 

(15478) PLEASE STASH ;1 + ;2 + :2 + :3 + :4 

347 


DO ;2 SUB #1 <- #784 l #904 

348 


DO ;2 SUB #2 <- #0 

349 


DO (30300) NEXT 


52 Selected Papers on Fun and Games 


350 DO :1 <- ;1 SUB #1 

351 DO :2 <- 1 ; 1 SUB #2 1 ' 1 #32768^#0 1 

352 DO (1509) NEXT 

353 DO .984 <- "V.984^ 1 :4'#2 , "~#1 

354 PLEASE RETRIEVE ;1 + ;2 + :2 + :3 + :4 

355 PLEASE RESUME #1 

356 

357 DON’T STOP READING YET: TWO IMPORTANT UTILITY ROUTINES REMAIN 

358 

359 UTILITIES 

360 

361 DOING (CMP) NEXT IMMOBILIZES :1 IF :1 < :2 

362 HERE I USE A SLICK TRICK FROM THE ORIGINAL INTERCAL DIVISION ROUTINE 

363 (23438) PLEASE STASH .3 + :1 

364 DO :1 <- 1 "V ’ :1'"#65535«‘#0" ’ i ’ :2~"#65535<;#0 " "#0<!#65535" 1 t 

365 1 "V , :r M #0(!#65535 l " i 1 :2‘"#0(!#65535 ~ "#0#65535'" 

366 DO .3 <- 1 :2~ : 1 1 * 

367 V ' "V: 1~ : l" - "#65535^#0" 1 t #32768"'"#0(!#65535' 1 1 i 

368 " l V:r:l"'"#0(!#65535" 1 " 

369 PLEASE RETRIEVE :1 

370 DO (2010) NEXT 

371 DO (2011) NEXT 

372 (2010) DO (2006) NEXT 

373 PLEASE IGNORE :1 

374 (2011) DO RETRIEVE .3 

375 DO RESUME #2 

376 

377 DOING (TIX) NEXT IS INTENDED TO SIMPLIFY LOOPS ON THE VARIABLE .1 

378 IF .1 = .1, NEXTING IS TURNED OFF 

379 OTHERWISE .1 IS INCREASED BY +1 OR -1, WHERE THE 

380 INCREMENT IS -1 IF (UP) HAS JUST BEEN ABSTAINED FROM 

381 (29904) PLEASE STASH .1 + .2 + .3 + .4 

382 DO .3 <- "'"V.6|U"*#21845' * l,, V.6*!.l"'#21845 l ” ‘ #1 

383 DO (2012) NEXT 

384 PLEASE ABSTAIN FROM NEXTING 

385 PLEASE RETRIEVE .1 + .2 + .3 + .4 

386 PLEASE RESUME #1 

387 (2012) DO (2006) NEXT 

388 DO .1 <- .6 

389 (711) DO (2013) NEXT 

390 PLEASE REINSTATE (711) 

391 DO .2 <- #1 

392 DO (1010) NEXT 

393 DO .6 <- .3 

394 DO (2014) NEXT 

395 (2013) DO (1020) NEXT 

396 DO .6 <- .1 

397 (2014) PLEASE RETRIEVE .1 + .2 + .3 + .4 

398 DO RESUME #3 


TPK in INTERCAL 53 


399 

400 PLEASE NOTIFY THE AUTHOR IF YOU'VE BEEN ABLE TO 

401 UNDERSTAND ALL OF THIS; BUT PLEASE DON'T SEND EMAIL 

402 

403 FINAL PUZZLE: WHAT IS SO INTERESTING ABOUT 885205232? 

Hints For Understanding Table 3 

Let’s pretend that we’re the computer that performs this program. Line 
001 tells us to “abstain from” line 002, the statement whose label is 
29733. That means we should ignore it, if we get to it (and of course 
we immediately do). It’s good to ignore that statement, because it 
doesn't conform to INTERCAL ’s syntax; an erroneous statement would 
otherwise abort the run, with the rude message CORRECT SOURCE AND 
RESUBNIT [sic]. Error- filled statements have been sprinkled liberally 
through this program, in places where the program shouldn’t ever go, 
because INTERCAL provides no other way to give helpful comments. 

A much more drastic type of abstention is specified on line 384, 
which says that we must abstain from every statement that uses the NEXT 
command (namely the statements on lines 020, 024 , 027, 029, . .., 395). 
Every statement has an “abstention flag,” either on or off; an ABSTAIN 
command turns one or more of these flags on. Conversely, a REINSTATE 
command, as on line 036 or 390, can be used to turn them back off. 

Spaces and line breaks are ignored throughout an INTERCAL pro- 
gram, except within the keywords PLEASE and DO. They appear in Table 3 
only to enhance readability. 

If NOT or N'T immediately follows PLEASE or DO or PLEASE DO, as on lines 
007, 015, 083, 094 , . ■ ■ , 401 , the statement’s abstention flag is initially 
on. Thus we actually begin to perform the TPK program by skipping 
past many lines of opening comments, until reaching line 020. There we 
are told to invoke the subroutine whose label is (6534) . 

The teleprinter code on line 017 is important, because it explains 
why subroutine (6534) was given that label: 6534 is the number that 
Alan Turing knew as INI, using the notation that he advised everyone to 
learn when working with the early Manchester computers. Indeed, the 
subroutine in question begins on line 090; line 089 refers to it by the 
symbolic equivalent (INI) , because its purpose is to do a bit of initializa- 
tion. Similarly, (22919) on line 027 calls the (UNP) subroutine of line 301 , 
in order to unpack data. Notice that Turing’s notation was little-endian 
(right-to-left): He denoted 22919 by UNP, not PNU. 

How do subroutines work in INTERCAL? Easy: The NEXT command 
on line 020 places the location of the following statement (line 021 ) onto 


54 Selected Papers on Fun and Games 

a stack, and jumps to line 090, the statement labeled (6534). Lines 090 
and 091 set up a three-element array ;1 and a two-element array ;2; then 
the RESUME command on line 092 pops one (i.e. , #1) element oft the stack, 
and transfers control there. We’re back from the subroutine, at line 021 . 

Line 021 initializes the array x (which is ; 29 , teleprinterwise), declar- 
ing it to be a pair (* 1 , 2 : 2 ) °f 32-bit numbers. This implementation of 
TPK works with “double-double precision” values, meaning that x rep- 
resents the number *1 + X 2 / 2 22 . 

Line 022, similarly, declares a to be a two-dimensional array, 11x2. 
It has entries ( a * 1,0,12) for 1 < i < 11; in other words, it’s an array of 
eleven double-doubles. 

Lines 023 through 036 are TPK’s first loop on i (aka .6 or .1), an 
index variable that runs from 0 up to 10. First we set * <— 0 in 023 \ 
then we “call subroutine (1)” in 024 ■ But that instruction turns out to 
be “go to (1)” in reality, because the FORGET command in 025 discards 
the top element of the stack. 

Incrementation and testing of the loop variable are handled by the 
(TIX) subroutine that’s called in lines 033 through 036. Those lines es- 
sentially mean “if i = 10, exit the loop [by disabling the go-to statement 
on line 035}\ otherwise set i 1 and return to (1).” 

When you’re ready to see how the (TIX) routine on lines 377-398 
actually accomplishes this magic, you should appreciate the fact that the 
command REINSTATE NEXTING also reinstates (UP), the statement on line 389. 
Now, however, we will stick to high-level programming constructions 
instead of delving into minutiae of the low-level utilities. 

The body of the first loop on i runs from 026 to 032. Line 026 
inputs a 32-bit number, which is unpacked to the double-double ;1 by 
the (UNP) routine invoked by line 02 7 . In other words, each execution of 
the loop begins by setting ;1 to the next input value. 

Then the loop proceeds to set j <— i+ 1 in lines 028, 029 , 030. Here’s 
how: All statements with labels (1000)- (1999) are part of INTERCAL’s 
standard System Library [7], which the compiler appends to the code 
of any program that refers to such a label. Thus line 029 invokes the 
standard subroutine (1020), which increases .1 by one. 

Lines 031 and 032 complete the body of the loop by setting aj <— ; 1 . 

The next loop, in lines 037-056, is similar, but it causes i to vary 
from 10 down to 0. The ABSTAIN command on line 054 causes (TIX) to 
decrease i instead of increasing it. 

Line 039 sets ov «— 0; this variable will be set to 1 if an overflow 
occurs during the subsequent calculation. The next few lines set x •<— 
aj, where again j = i + 1. Then line 045 calls subroutine (F), which 


TPK in INTERCAL 55 


sets variable ;1 equal to f(x) as defined by the TPK formula. The 
(PAK) subroutine, invoked on line O 46 , then computes the scaled-decimal 
integer :1 that corresponds to ;1; and (OVC) on line 047 changes :1 to 
2 32 — 1 if overflow had occurred. 

Lines 048-051 present an interesting high-level way to achieve the 
effect of “if :1 is 400 or more, change :1 to 999.”* First we set :2 to 400 
(line 048 ); then we call (CMP) (line 049); then we set :1 to 999 (line 050). 
Subroutine (CMP) amazingly causes the latter instruction to be ignored 
if :1 was less than :2, by invoking the command IGNORE :1 (line 373) in 
such a case. Line 051 undoes any ignoring that (CMP) might have done. 

After the second loop, the program reaches its normal end (line 057). 

So we turn now to subroutine (F) . The STASH commands on lines 063 
and 066 place two arrays onto an auxiliary stack, independent of the 
nexting stack, without changing their values, so that ;1 and ;2 can be 
temporarily modified. These arrays are restored to their former states 
by using RETRIEVE commands {076 , 080). 

Thus (F) basically follows the standard TPK pattern: First we set ;1 
and ;2 to x. Then in 069 we use subroutine (MLX) , which replaces ;1 by 
;1 x ;2, to form x 2 ; and we invoke it again to form x 3 . After multiplying 
by 5 we put 5x 3 in ;2. Then (line 076) we put x back into ;1. The next 
three lines invoke (ABX) to replace ;1 by its absolute value, then (RTX) to 
replace ;1 by its square root, and (ADX) to increase ;1 by ;2. That gives 
us /(x), so (F) is done. 

The classic TPK algorithm has therefore been entirely specified by 
almost-palatable “high level” INTERCAL code, on lines 020-081 of Ta- 
ble 3. The remaining lines are my extensions to the standard library, 
namely the routines for double-double precision arithmetic (including 
square root), together with the (CMP) and (TIX) utilities. 

I heartily encourage the reader to study these extensions, as stated 
earlier, because they represent the soul of INTERCAL’s machine. But 
I shall confine myself in the rest of these notes to rather sparse hints 
about the shenanigans that I pulled when writing them. 

It’s best to start small, and to figure out why line 103 of (OVC) exits 
by 2 levels if ov = 1, but by 1 level if ov = 0. 

Addition and subtraction in double-double precision are, of course, 
quite straightforward because they reduce to addition and subtraction 
of 32-bit numbers. But before you can totally understand (ADX) and 
(SUX) you need to know the specs of several standard library routines: 


* The TPK algorithm actually says that 999 should not be used if the value 
is exactly 400. Fortunately this boundary case can never arise. 


56 Selected Papers on Fun and Games 

(1010) sets .3 4— (.1 — .2) mod 2 16 . (1509) sets :3 4— :1 + :2 and :4 4— 
1 + carry; (1500) is similar, but it aborts if there is a carry. (1510) sets 
:3 4— ( : 1 — :2) mod 2 32 . (1540) sets :3 4— : 1 X : 2 , but aborts if the product 
exceeds 2 32 — 1. And (1550) sets :3 4— [_:l/:2j if :2 / 0, otherwise :3 4— 0. 

The mess on lines 139-142 looks horrible at first glance, but in 
reality it simply complements the double-double number in ;2. 

Double-double multiplication is basically reduced to a series of mul- 
tiplications of short numbers by short numbers. 

The double-double square root routine, (RTX) , consists primarily of 
a loop on i from 1 to 49, using (TIX) in line 284 ■ Variable ;3 holds the 
remainder-so-far and ;4 holds the complement of the sqrt-so-far; vari- 
ables :1 and :2 hold the bits that haven’t yet been examined. We begin 
by jumping into the middle of the loop, where lines 267-276 compute 
the next bit .3 of the square root (left to right) by essentially setting 

;1 ;3 + ;4 + 1, and .3 «— [;1 ^ 0 or .2 / 0] x [carry occurred], 

where .2 holds the two leading bits of : 1 . Then lines 277-282 set ;1 4- ;3 
if .3 = 0. In the earlier portion of the loop, lines 234-256 set 

;3 4— 4 X ;1 + (.2 — .3)/2 32 and ;4 4- 2 X ;4 + (1 - ,3)/2 32 , 

then lines 257-266 shift (:1, :2) two bits to the left. 

Regarding line 296 , 1 admit that it isn’t great programming practice 
to let 50 items accumulate on the nexting stack. But hey, I saved a line 
of code by doing so. 

The climax of this program is (UNP) , the unpacking subroutine, which 
is primarily concerned with computing the 32 leading bits of the frac- 
tion (:1 mod 1000000)/1000000 and rounding them properly. Variable 
:4 runs through the values 2 31 , 2 30 , . . . , 2°, while the two components of 
an auxiliary array ;2 accumulate the answer and its complement. The 
basic idea is simply to double the fraction repeatedly, modulo 1, and to 
remember where carries occurred. 

Let x and y denote : 1 and ; 1 , respectively. Lines 321 -329 essentially 
put 2x into y 2 and then z mod 2 20 into 2 / 3 -[ z / 2 20 j, where z — 2 20 + 
2x — 1000000; therefore j /2 has been set to 2x mod 1000000. This value 
replaces x in line 31 7 . 

Line 316 launches a sneaky trick that can be perpetrated only in 
INTERCAL. A close inspection shows that line 340 temporarily changes 
it from DON'T RESUME #1 to DO RESUME #1, so that we can go through the loop 
one more time, finally delivering a properly rounded result in line 335. 


TPK in INTERCAL 57 


Another noteworthy trick, which can be found in Woods and Lyon’s 
original standard library [7], appears in lines 364-368. The gist is that 
one can compute t <— [x>y\ by doing just a few xor, shift, and selection 
operations: z <— x (By, t <— z e- z ~ z, z <— z © (z3>l), t «— t ~ z. 

Using the Compiler 

If your computer doesn’t already have an INTERCAL compiler, you can 
readily install the one developed by Eric Raymond [4], assuming that 
you have a UNIX-inspired operating system. The program tpk . i in 
Table 3 can be downloaded from my website [2], together with sample 
input data tpk. in and the corresponding output tpk. out, so that you 
can watch it in action and do your own experiments. 

I tested Table 3 on the following eleven values: 0.000000, 0.000001, 
0.015625, and 4.000000 (when the square root is exact); 5.000000, 
3.141592, 3.141593, and 0.768033 (“random” data); 4294.967295 (the 
maximum possible input); 4.301409 and 4.301410 (near the root of 
f(x) = 400). To input a value like 0.015625, say, INTERCAL wants 
you to type ONE FIVE SIX TWO FIVE; so that’s what actually appears in the 
sample file tpk. in mentioned above. 

The corresponding outputs — which appear in tpk. out using IN- 
TERCAL’s version of Roman numerals, but converted here to scaled dec- 
imal— are 0.000000, 0.001000, 0.125019, and 322.000000; 999.000000, 
156.803740, 156.803888, and 3.141591; 999.000000; 399.999898 and 
999.000000. These results are perfectly rounded, except for the fact 
that 156.803889 would have been slightly better than 156.803888. (We 
can’t expect perfect accuracy when fixed-point scaled arithmetic is used 
on a problem like this; an error of e in x leads to an error of roughly 
(l/(2i/a:) + 15x 2 )e in f(x).) 

The total computation in this example amounted to the dynamic 
execution of 3,903,231 INTERCAL statements (including 3,760,185 in 
the standard library), plus 6,179 abstentions (5,801 of which were within 
the library). 

By the way, many other esoteric programming languages [5] now 
exist, inspired by INTERCAL as their canonical example yet wildly dif- 
ferent. I don’t think TPK has yet reached them all. Go hack. 

References 

[1] Donald E. Knuth, Combinatorial Algorithms, Part 1, Volume 4A 
of The Art of Computer Programming (Upper Saddle River, New 
Jersey: Addison- Wesley, 2010). 


58 Selected Papers on Fun and Games 

[2] Donald E. Knuth, tpk . i in “Programs to read,” online at http : 
/ / www-cs-f acuity . Stanford . edu/ ~knuth/ programs .html [ac- 
cessed July 2010]. 

[3] Donald E. Knuth and Luis Trabb Pardo, “The early development 
of programming languages,” in Encyclopedia of Computer Science 
and Technology, edited by Jack Belzer, Albert G. Holzman, and 
Allen Kent, Volume 7 (New York: Marcel Dekker, 1977), 419-493. 
Reprinted in A History of Computing in the Twentieth Century, 
edited by N. Metropolis, J. Howlett, and G.-C. Rota (New York: 
Academic Press, 1980), 197-273. Reprinted with revisions and ex- 
tensions as Chapter 1 of Selected Papers on Computer Languages, 
CSLI Lecture Notes 139 (Stanford, California: Center for the Study 
of Language and Information, 2003), 1-94. 

[4] Eric S. Raymond, The INTERCAL Resources Page (5 July 2008), 
http://www.catb.org/~esr/intercal [accessed July 2010]. 

[5] Wikipedia, “Esoteric programming language,” online at http : //en . 
wikipedia.org/wiki/Esoteric_programming_language [accessed 
July 2010]. 

[6] Wikipedia, “Trabb Pardo-Knuth algorithm,” online at http://en. 
wikipedia. org/wiki/Trabb_Pardo-Knuth_ algorithm [accessed 
July 2010]. 

[7] Donald R. Woods and James M. Lyon, The INTERCAL Program- 
ming Language Reference Manual (privately published in 1973), 
38 pages. A revised version is available on the Internet [4]. 

I like to think of C-INTERCAL as being much in the spirit of the 
Potrzebie System of Weights of Measures. 

- ERIC S. RAYMOND, in an email to the author (18416.29075 C.D.) 


Chapter 8 


Math Ace: The Plot Thickens 


[Originally published in Engineering and Science Review, Case Institute 
of Technology , 3, 1 (November 1959), 45; 3, 4 (May 1960), 24.] 

The classical formulas shown to analytic geometry students always have 
familiar shapes when graphed: circles, ellipses, parabolas, lemniscates, 
and so on. The graphs of textbook equations invariably lead to lines or 
curves. But there are many relatively simple equations that are satisfied 
by whole areas of the plane, not just by points that lie on paths. For 
example, the equation “|x| = x" is satisfied by all points that lie in the 
first and fourth quadrants (all points with x > 0, regardless of y). 

After playing around with equations like this during odd moments 
of my freshman year, I began to notice that interesting shapes could be 
produced by a variety of techniques. In fact, the discovery of such “shady 
equations” might well lead to a new and highly impractical branch of 
analytic geometry. One of the unusual formulas derived was the equation 

1 20 - \x + y\ - | a; - y|| - 20 + \x + y\ + \x - y\ 

+ 1 18 — \x + y\ — \x — y\ \ + 1 16 — |x + y| — \x — y\\ 

— 2 1 17 — \x + y\ - |x-y|| 

3 3 - 0 | 

+ X! (l 2 ~ I* + y + 4 il - \ x - y + 4fc + 2|| 

i =- 3 fc =li|— 4 \ 

+ 2 - \x + y + 4j\ - \x - y + 4k + 2|J =0, 

which happens to be satisfied by precisely the points ( x , y) that are 
plotted in Figure 1 on the next page. 

Calculus pros are encouraged to guess the shape, before turning the 
page to see the answer. Take a sheet of graph paper and systematically 
pick values for x and y, putting a black dot wherever the equation holds. 
For example, you’ll find that the values x — 0 and y = 0 nicely satisfy 
the equation, while x = — 1 and y = +1 do not. 


59 


60 Selected Papers on Fun and Games 

y 

+ 12 
+ 10 
+ 8 
+ 6 
+ 4 
+ 2 
0 

-2 

-4 

-6 

-8 
-10 
-12 

-12 -10 -8 -6 -4 -2 0 +2 +4 +6 +8 +10 +12 

FIGURE 1. The points that satisfy the mysterious equation. 

Right, you guessed it: A chessboard. 

Or maybe you thought it was something else? To squelch any objec- 
tions by skeptics, I fed the formula into the 650 computer for verification. 
The machine tried 6400 points on the plane, at intervals of one half for 
the values of x and y, and punched 80 cards to illustrate the graph that 
it found. (This process took approximately an hour.) The result was 
perfect agreement with the predicted graph; the computer’s version is 
reproduced in Fig. 2, but omitting the 39 cards that were blank. A 
rigorous analytic proof could also be given. 

One added note: It is theoretically possible to put chessmen into any 
position of this diagram. But the resulting equation would take several 
pages to reproduce. 

A Sequel 

To prove yet again that mathematicians are able to make simple things 
complex, I went back to the drawing board and wrote down another 
equation for intrepid plotters. 

The pile of hair below Figure 2 is mystery formula number two. Can 
you psych this one out, now that you totally understand Figure 1? 
Some of my former friends have been anticipating my burial plot. 





62 Selected Papers on Fun and Games 

y 


+ 20 



-20 


-15 -10 -5 0 +5 +10 +15 

FIGURE 3. Solution to the second mysterious equation. 


Addendum 

1 noticed some years later that the simple equation |_:rj + [yj = 2 [a; /2j + 

2 Ly/2j + 1 defines an infinite chessboard, although it includes only two 
of the four boundary edges of each filled square. 


Chapter 9 


Billiard Balls in an Equilateral Triangle 


[Originally published in Recreational Mathematics Magazine #14 (Jan- 
uary-February 1964), 20-23.] 


This note investigates the infinite cyclic paths that can be traced by a 
billiard ball as it ricochets inside an equilateral-triangular table. We are 
given the equilateral triangle ABC and a point X on the side AB. We 
want to determine all paths that start at X and bounce off the sides of 
the triangle according to the law of reflection, in such a way that the 
ball will eventually return to X and start the same pattern once again. 

We let x be the ratio of the lengths AX/AB\ 
thus 0 < x < 1. Taking AB to be of length 1, 
then AX has length x, and the altitude of 
the triangle is \/3/2. Figure 1 shows an ex- 
ample of such a triangle, together with 
a closed path (in gray) that is a par- 
ticular solution to our problem. The 
path starts and ends at X by mak- 
ing some angle 0 with the bottom 
edge. Since this angle determines 
the path completely, the prob- 
lem becomes one of determin- 
ing exactly which angles 6 
will lead to cyclic paths. In 
Figure 1 we have 0 = 60°, 
which defines an inter- 
esting six-bounce cycle. Two other cases of interest are 6 = 90° and 
6 — 30°, which yield unusual cycles in which one half of the path re- 
traces the other half but in the opposite direction. (Those cases are 
illustrated in Figures 5 and 7 below.) All of the values of 6 mentioned so 
far will give solutions regardless of the position of A; in fact, we will see 
that the permissible values of 9 are actually independent of X in general. 



Figure 1. 


63 


64 Selected Papers on Fun and Games 

The law of reflection used here is the familiar one that the “angle 
of incidence equals the angle of reflection.” There is a particular case 
that merits special study, however: What do we do when the path leads 
directly into a corner of the triangle? Figure 2 shows the situation when 
the path comes very close to a corner as the ball bounces three times; 
the limiting behavior of this case leads us to the reflection law shown in 
Figure 3 when the path hits the corner exactly. 




Our problem can be solved by expanding the diagram in such a 
way that the ball’s path is a straight line; this can be done by repeat- 
ing the triangle ABC infinitely many times, as indicated in Figure 4. 
In this diagram the triangle ABC appears in six different orientations. 
Straight lines on this figure, such as the gray lines shown, give paths 
in the original triangle that satisfy the reflection law if the diagram is 
folded appropriately. Conversely, any path that satisfies the reflection 
law corresponds to a straight line in this diagram. Path L corresponds to 
Figure 5, path N corresponds to Figure 6, and path P corresponds to 
Figure 7; path M corresponds to Figure 1. 

To solve our problem, we observe that each of our paths begins to 
repeat at some point in time when it passes through one of the copies 
of the point X. We may assume, by the law of reflection, that the path 
begins by traveling upward and to the right, unless 6 = 90°. Now the 
point X where the path begins to repeat might conceivably appear on 


Billiard Balls in an Equilateral Triangle 65 






a line with the “/ ” slope; but the path makes an angle of 9 + 120° with 
that line, not 9. A second possibility is that the cycle point X occurs on 
a line with the “ \” slope. But we see from Figure 8 that this situation 
can occur only when 9 = 60°, and indeed only in this case when x = 
The path corresponding to 9 — 60° and x = \ is B 

a very special case that occasionally behaves quite 
differently from the less symmetrical cases, and we 
will have to treat it specially. 

We are now left with the case where the repeti- 
tion starts at a point A on a line of horizontal “ ” 

slope. Not only is such a case possible, it is easy to 
see conversely that every line that connects two X 
points on different horizontal lines is a cyclic path. 

These X points therefore play an important role in 



Figure 8. 






66 Selected Papers on Fun and Games 

our investigation, and they are labeled in Figure 4 with coordinates of 
two types, either (to, n) or (to + n + |), where m and n are integers. 

We conclude that all possible cyclic paths are obtained by connecting 
point (0,0) to one of the points labeled (p,<?) in Figure 4, and that all 
paths of this type are cyclic. The tangent of the angle 9 for such a path 
is easily determined; it is equal to q/{pV 3). These observations prove 

Theorem 1. If 0 < 6 < 90°, the path corresponding to theta is cyclic 
if and only if tan 9 = r/\/ 3, where r is a positive rational number. □ 

Let us now investigate the cyclic paths a little more closely. Sup- 
pose we are given 9 with tan# = r / \J 3 and r > 0. Then the path passes 
through all points (p, q) where r — q/p. The first such point may be de- 
termined as follows: Suppose that the fraction q/p is in lowest terms. If 
p and q are both odd, the path passes first through the point (p/2, q/ 2); 
otherwise it passes first through (p, q) . This reasoning leads to 

Theorem 2. The length of the path traveled in each cycle may be 
determined as follows: Let tan 9 — q/(pV 3) where p and q are integers 
with no common factor, and where p > 0, q > 0. Then the length is 
^/9p 2 + 3q 2 / 2 when p and q are both odd, and \J 9 p 2 + 3 q 2 otherwise — 
except that the length is only 3/2 when 9 — 60° and x — 1/2. □ 

Corollary. If x / 1/2, the shortest path length is \/3: it occurs when 
0 = 30° and when 9 = 90°. □ 

We now turn to the number of “bounces” in each path. To account 
for the degenerate cases when the path heads directly into a corner, we 
will count that event as three bounces (motivated again by Figure 2). It 
is not hard to see that the path from (0,0) to (p, q) in Figure 4 passes 

2q lines with slope “ ”, |3p — q\ lines with slope “/”, and 3p + q lines 

with slope “ \” . This calculation yields our next theorem: 

Theorem 3. The number of bounces occurring in each cycle may be 
determined as follows: Let p and q be as in Theorem 2. Then the number 
is q+max(3p, q) when p and q are odd, otherwise it is 2q r +max(6p, 2 q) — 
except when 9 = 60° and x = 1/2, when the number is 3. □ 

Corollary. If x ^ 1/2, the least number of bounces per cycle is 4; it 
occurs when 9 — 30° and when 9 = 90°. The number of bounces for 
x 1/2 is always even. □ 

Finally, we consider the following fallacious argument (see Mar- 
tin Gardner’s “Mathematical Games” in Scientific American 209, 3 
(September 1963), page 252), which motivated this entire study: A line 


Billiard Balls in an Equilateral Triangle 67 

is drawn between two corresponding X’s as shown in Figure 9. Moving 
from the lower X to the upper X corresponds to the path of a billiard 
ball that is driven “against side B-C so that it rebounds, hits side A-C , 
then returns to its original position on side A-B v ; and we might think 
at first glance that the same path will then recur. But the path doesn’t 
really begin to recycle immediately unless X bisects AB, as we have seen 
above. We now inquire under what circumstances the path of Figure 9 
is even cyclical if we continue to extend it. Thus we compute 



where x — AX/ AB, and we see that ( 1 + a?) /(I — x) = r must be rational. 
This equation implies x = (r - 1 )/(r + 1), so we get our final result: 

Theorem 4. The line in Figure 9 leads to a cyclic path if and only if 
AX/ AB is rational. □ 


B 



Figure 9. 

Addendum 

These billiard-ball paths have been independently investigated from a 
somewhat different point of view by Andrew M. Baxter and Ronald Una- 
ble, “Periodic orbits for billiards on an equilateral triangle,” American 
Mathematical Monthly 115 (2008), 479-491. 


68 Selected Papers on Fun and Games 

I wrote to Martin Gardner on 5 September 1963, saying “Dear 
Mr. Gardner: I suppose you’ll be getting much more mail this month 
than usual, because at last you goofed! ... If I hadn’t noticed this error, 
I’d have put the magazine down and forgotten all about it, but as it was 
I spent the greater part of the afternoon working on this topic! It’s easy 
to prove that there is only one cyclic path which has only three bounces 
per cycle, i.e., only one solution to the problem you stated. For if we 
denote the incidence angles by a, 6 , c we find from the diagram 


C 



that a + b + c — 180° [since, e.g., the sum of the interior angles of the 
middle triangle is 180° = (180° — 2a) + (180° — 26) + (180° — 2c)]; and this 
shows further that a — b = c = 60°. The enclosed note discusses these 
things in a little more detail, and they are interesting because they are 
so completely elementary. . . . Well, it has been fun to catch you once.” 

Martin responded almost immediately, on 15 September. Neither of 
us knew it at the time, but this — our first exchange — was destined to 
become the beginning of a long correspondence, writing back and forth 
every few weeks. He said “I think your note deserves full publication 
somewhere,” and he recommended Recreational Mathematics Magazine 
because he knew that an article about ball-bouncing in an ellipse was 
already scheduled to appear there. 

Many mathematicians have similarly benefited from Martin’s kind- 
ness and good counsel at early stages of their careers. 


Chapter 10 


Representing Numbers Using Only One 4 

[Originally published in Mathematics Magazine 37 (1964), 308-310.] 

In the Mathematical Games section of Scientific American, January 
1964, Martin Gardner asks his readers to try their hand at the well- 
known problem of representing the number 64 using precisely four, three, 
and two 4’s, respectively, combined with arithmetic operations. The 
“two-4” problem was first posed by J. A. Tierney (see [1]), and some of 
the answers given were 

64 = vW(4 4! ) = V (4 r(4) ) = 4L ln4! J = (p(ip(4 4 )) = ^(4!)^ = 4^ (7r ( 4! )). 

It is the purpose of this note to show that the number 64 can be rep- 
resented with only one 4, and indeed this may be true of all positive 
integers. 

Using only the three operations v 7 , |J, and and the single digit 4, 
we have 

64 = [v 7 'WW\/WV[VWWVWV[y/^IVy/WVy/'JWW 
[Wy/y/WW^VWy/y/Vy/WW 
IVlVLv 7 v 7 V 7 v / v 7 (4!)!j !j !j !j !j !j !j !j . 

(In this representation, the notation ^Jx\ stands for a/(x!), not ( y/x)\ . 
Parentheses have been placed in the subformula ‘(4!)!’ because the un- 
parenthesized expression ‘4!!’ traditionally means 4-2.) 

To verify this formula we will compute successively the quantities in- 
side each of the nested brackets. The innermost floor brackets represent 
the number 5, since 

5 32 = 232 83064 36538 69628 90625 

24! = 6204 48401 73323 94393 60000 
6 32 = 79586 61109 94640 08843 91936 
69 


70 Selected Papers on Fun and Games 

and hence |_vV\AA/24!J = 5. The next level of brackets obviously 
gives 10, since 10 = [\/5!J. Proceeding similarly, we can evaluate the 
fcth brackets to obtain the integer ak, where 

a k < a fc-i- < ( a k + l) 2 
for some appropriate integer t. The details are: 


k 

Uk 

t 

2* 

4 

&k—l ■ 

(flfc + l) 2 

3 

1904 

1 

36 25216 

36 28800 

36 29025 

4 

442 

11 

6.7 x 10 5417 

4.2 x 10 5419 

6.8 x 10 5419 

5 

6673 

8 

1.062 x 10 979 

1.097 x 10 979 

1.104 x 10 979 

6 

577 

13 

3.6 x 10 22619 

9.1 x 10 22623 

5.2 x 10 22625 

7 

422 

9 

1.4 x 10 1344 

2.5 x 10 1344 

4.9 x 10 1344 

8 

64 

9 

5.8 x 10 924 

2.1 x 10 926 

1.6 x 10 928 


With such large numbers, of course, logarithms are used for the calcu- 
lations. Logarithms of factorials up to 1200! are given to 18 places in 
J. Peters, Ten Place Logarithm Table 1 (New York: Ungar, 1957). The 
logarithms of larger factorials are easily computed by means of Stirling’s 
approximation. 

Notice that = L'\/ a: J> so th e fl° or operation is needed only 

around the final result and before factorials are taken. Since 3 = |_\/10j, 
we can represent 3 with one four, hence also 3! = 6, and so on. It 
seems a plausible conjecture that all positive integers possess such a 
representation, but this fact (if true) seems to be tied up with very deep 
properties of the integers. 

The referee has suggested a stronger conjecture, that a representa- 
tion may be found in which all factorial operations precede all square 
root operations; and moreover, if the greatest integer function is not 
used, an arbitrary positive real number can probably be approximated 
as closely as desired in this manner. If N y. is the number ( ■ • ■ ((4!)!)! • • • )! 
with k factorial operations, this conjecture is equivalent to the statement 
that the values of 

l°g 2 (-^fc / 2 L‘°S 2 ( log 2 JVfc )J> ) k = 1, 2, 3, ..., 

are dense in the interval (1 . . 2). 

A computer program was written to see what small numbers can be 
represented in a fashion similar to our formula for 64. For all x and y 
less than 1000, the machine determined whether or not 


Representing Numbers Using Only One 4 71 

for some integers u and v, provided that the calculations could all be 
carried out without numbers becoming too large, and provided that 
round-off error could be shown to have absolutely no effect. If we write 
y ~ > x when this relationship holds, we can also write y — >-> x to mean 
that y -> ?/i -> y 2 -+ • • • -» y k = x, for some y 1 , y 2 , . . . , yk ■ Then the 
number n can be represented with just one 4 whenever 4 — >— >• n. The 
results of this computer run were that 4 » n for all n < 208. The fact 

that 208 was not obtained is probably due to the limited search that 
was carried out; however, it is interesting that all numbers n < 200 can 
be written as 4 — » ni — ► n 2 — > • • • — > n where each n, is at most 999. 

A further improvement can be made by using negation in connection 
with the other operations, since — [_— xj is the least integer greater than 
or equal to x. This possibility has not been fully explored. It can be 
used, for example, to extend the list of numbers represented in a simple 
way by four l’s to at least 37, using 

35 = -|V(11 + l)/(— -1)J , 

36=( v / (l/.i))!(v'(l/.i))!, 

37 = 1 - L-Vnj/.i, 

and the list of representations of 1 through 34 in [2], (Here ‘.i’ stands 
for ‘.1111...’.) The latter article contains an excellent bibliography. 

References 

[1] J. A. Tierney, Elementary problem E631, “Two fours,” American 
Mathematical Monthly 51 (1944), 405; 52 (1945), 219. 

[2] Marjorie Bicknell and Verner E. Hoggatt, “64 ways to write 64 using 
four 4’s,” Recreational Mathematics Magazine #14 (1964), 13-15. 

Addendum 

I’ve modernized the notation that was used in 1964, when the “floor 
brackets” |_*J had not yet been invented. At that time |_a;J was called 
the “greatest integer function of x” and written [ar]. 

Martin Gardner’s original column from January 1964, which insti- 
gated my work, has been thrice reprinted (with significant alterations) as 
Chapter 5 of a series of ever-longer books: The Numerology of Dr. Matrix 
(New York: Simon and Schuster, 1967); The Incredible Dr. Matrix (New 
York: Charles Scribner’s Sons, 1976); The Magic Numbers of Dr. Ma- 
trix (Buffalo, New York: Prometheus, 1985). His discussion sketches the 
history of similar recreations and refers to many related publications. 


72 Selected Papers on Fun and Games 

The referee’s conjecture, about the numbers obtainable by repeated 
factorialing followed by repeated square-rooting, had previously been 
stated at the close of an elegant note by J. H. Conway and M. J. T. Guy, 
“n in four 4’s,” Eureka: The Archimede ans’ Journal 25 (1962), 18-19. 
Although this conjecture is eminently plausible, it seems to be well be- 
yond any conceivable explicit proof. 

Suppose we define the sequence Nk by letting IVo = 4 and N k + i = 
iVfc!; surely there’s no way to calculate an integer k for which the 2' J th 
root of N k lies between 64 and 65 for some v. (This would mean that 
the binary representation of log 2 N k begins with 1 1 and is less than the 
leading digits 11000000101101110011110 ... of the binary representation 
of log 2 65.) A little analysis shows, for example, that 

2 85 < log 2 N 3 < 2 85 + 2 83 and 2 285 < log 2 N 4 < 2 286+283 . 

Furthermore, it isn’t extremely difficult to determine the leading bits 
111110000000011010001110 ... of log 2 JV 4 . With a century or so of com- 
putation, one might also determine the leading bits of log 2 1V 5 , which 
is approximately N 4 \og 2 N 4 . But it’s a safe bet that nobody will ever 
know whether the most significant binary digits of log 2 N e are 10 or 11. 

Thanks to 21st-century software, I can now redo the calculations at 
the end of my original note, by letting y — > x when 3 < x, y < 1000 and 

x=l\/y'-\ or x=\^J\^y\\\\\ 

no precautions about numbers becoming too large are now necessary. 
This directed graph on 997 vertices has a strongly connected component 
of size 963 that includes all vertices < 418. In particular we have 4 ->-> n 
for 3 < n < 417; all such n have a one-4 representation of length 765 or 
less, except for n = 337. The 85-symbol representation of 64 that I found 
in 1964 remains the shortest known, if we restrict ourselves to factorial, 
square root, and floor functions. The shortest such representation that 
I know for 337 has length 5175: 

0 3676 0 1422 O 6 O 42 

337 = LV IVLV V VLn/LV L\/(40-J!J!J!JUU-J • 

With the ceiling function we can of course do better. The best rep- 
resentation that I currently know for “64 with one 4,” eschewing exotic 
unary operations such as !! and j, is 

64 = [vvvfyvvvvvvvvvv 

VVVV |vV V [■ VVVVV(U) -I -J -J -1 •] • 


Chapter 11 


Very Magic Squares 


[Originally published in American Mathematical Monthly 75 (1968), 
260-264 .] 

A square matrix A is “magic” in the weakest sense when it has a general- 
ized “doubly stochastic” property, namely when all of its row sums and 
column sums have the same value s. The matrix is even more “magic” 
when the sums of its elements along certain diagonals are also equal to s. 

If A is an m x m matrix whose elements are denoted by A xy for 
1 < x, y < m, let us say that a generalized diagonal of A is the set of all 
A xy such that ax + by = c (modulo m), for some given integers a, b, c 
with a and b relatively prime to each other. For example, a 5 x 5 matrix 
has 30 distinct generalized diagonals, namely the sets of elements of the 
same value c in the following squares: 


mil 

23451 

35241 

42531 

54321 

12345 

22222 

34512 

41352 

53142 

15432 

12345 

33333 

45123 

52413 

14253 

21543 

12345 

44444 

51234 

13524 

25314 

32154 

12345 

55555 

12345 

24135 

31425 

43215 

12345 

x = c 

x + y = c 

x + 2 y = c 

x + 3 y = c 

x + 4y = c 

y = c 

When m is not prime, further types of generalized diagonals appear: 
if, for example, m = 6 we have the following 6 x 12 cases: 

111111 

234561 

351351 

414141 

531531 

654321 

222222 

345612 

462462 

525252 

642642 

165432 

333333 

456123 

513513 

636363 

153153 

216543 

444444 

561234 

624624 

141414 

264264 

321654 

555555 

612345 

135135 

252525 

315315 

432165 

666666 

123456 

246246 

363636 

426426 

543216 

x = c 

x + y = c 

x + 2y = c 

x + 3 y = c 

x + 4 y = c 

x + 5y = c 


73 


74 Selected Papers on Fun and Games 


345612 

525252 

165432 

456123 

513513 

123456 

561234 

141414 

321654 

123456 

246246 

123456 

123456 

363636 

543216 

456123 

513513 

123456 

345612 

525252 

165432 

123456 

246246 

123456 

561234 

141414 

321654 

456123 

513513 

123456 

123456 

363636 

543216 

123456 

246246 

123456 

2x + y = c 

2x + 3 y = c 

2x + 5 y = c 

3 x + y = c 

3x + 2 y = c 

y = c 


Clearly each row of a matrix is a special case of a generalized di- 
agonal, with a = 1 and 6 = 0; each column has a = 0, 6 = 1; and the 
principal diagonals have a = 1, 6=1, c=l and a = 1, 6 = —1, c = to. 

The object of this note is to give a short proof of the fact that 
a square matrix has equal sums along all of its generalized diagonals 
if and only if all of its elements are equal. In other words, only trivial 
squares can be “magic” with respect to all possible generalized diagonals. 
A proof was given by Rosser and Walker [1] when to is prime; they also 
stated that “This theorem is true for squares of any order. The proof is 
very complicated, so it is not included here. A typewritten copy of the 
proof has been deposited in the Cornell University library . . . 

More generally we have the following result for n-dimensional arrays 
of numbers: 

Theorem 1. The m n complex numbers A(xi , . . . , x„), for integers 1 < 
Xi, ... ,x n < m, satisfy the conditions 

. . . , x n ) | cqxi + • • • + a n x n = c (modulo to)} = s, (1) 

for all integers a\, . . . , a n , c with gcd(ai, . . . , a n ) = 1, if and only if 

A(xi, . . . , x n ) = sto 1- " for all x\, . . . , x n . (2) 

Proof. A proof that (1) implies (2) can be based on the idea of a “finite 
Fourier transform.” Let u = e 2lrt / m , and define 

a{h,...,t n ) = E w _t ' x A(x i,...,x„), (3) 

l<£i 

where t ■ x = t\Xx + • • • + t n x n . (We consider x = (xi, . . . ,x n ) and 
t = (ti, . . . , t n ) to be n-dimensional vectors of integers.) It follows that, 
when 1 < xi, . . . , x n < m, 

A(x i,...,x„) = Y] w t ' x a(f 1 ,...,< n ), 

m n z ' 

since the latter sum is 

E E u Hx - y) A( yi ,...,y n ) 

l<£i,...,t n <m l<yi ,...,y n <m 


(4) 



Very Magic Squares 75 

and since the sum over tj is a multiple of Y1T=i a geometric 

series whose value is 0 unless Xj = yj (modulo m). 

Now if = (t[d, . . . ,t' n d) and gcd(f' 1; . . . , t' n ) = 1, equa- 

tion (1) implies that 


C= 1 
m 

=*£ 


-cd 


A{x i, 


1 < Xi , . . . , x n < m and t' ■ x = c (modulo m) } 

c d _ J ms, if d = 0 (modulo m); 

, if d ^ 0 (modulo m). 


In other words, a(ti,...,t n ) is zero except when t\ = ■ • • = t n = 0 
(modulo to). Therefore the sum in (4) reduces to the single term with 
t± = • ■ • = t n = m, and (2) is immediate. 

To prove that (2) implies (1), we must show that the congruence 

a\x i + b a n x n = c (modulo to), 1 < x\, . . . , x n < m (5) 

has precisely m n ~ 1 solutions when gcd(ai, . . . , a„) = 1, regardless of the 
choice of c. Since there are integers a,[. . . . , a' n such that + • • ■ + 
a n a 'n — 1) we ma y take x x = ca^, . . . , x n = ca' n to obtain one solution 
of (5); then all solutions are obtained by adding solutions of (5) with 
c = 0 to this particular solution. Therefore there are the same number 
of solutions for c = 0, c = 1, . . . , c = m — 1; and this number must be 
to" - 1 , since to" combinations of xi, . . . , x n are possible. This analysis 
completes the proof of the theorem. □ 

Theorem 1 is the discrete analog of results on continuous functions 
discussed by Renyi (see [2,3]). 

Let us now consider whether Theorem 1 has hypotheses that are too 
strong. Is it perhaps possible to show that the array has constant values 
if we insist only that it has constant sums along a few of the generalized 
diagonals? The next result gives further information that follows from 
a slightly deeper analysis of the relevant structure: 

Theorem 2. Let lj = e 27Tl / m , and for 1 < xi, . . . , x n < m let 

A(x 1 ,...,x n ) = u t ' x , (6) 

where t = (ti, . . . ,t n ) is an integer vector with gcd(ti, . . . , t n ) = 1. Then 
A(xi , . . . , x n ) | a ■ x = c (modulo to) } = 0 


( 7 ) 


76 Selected Papers on Fun and Games 

for all integers a\, . . . , a n , c with gcd(ai, . . . , a n ) — 1, except when 

(a a n ) = (£t (modulo to) (8) 


for some integer £ relatively prime to to. 

Proof. Consider first the case when to = p e is the power of a prime 
number. Then some a*,, say cq, is not a multiple of p, and we can find b 
so that a\b = 1 (modulo to). The sum (7) is therefore 


£ w* x) , 

1<X2 


p(x) — tibc+(t 2 -btia 2 )x 2 -\ \-(t n -btia n )x n . 


Since w is a primitive mth root of unity, this sum vanishes unless 


t 2 = btia. 2 , . . . , t n = btia n (modulo m). 


And in that case 1 1 cannot be a multiple of p, since t\ = bt\ai and 
gcd(ti, . . . ,t n ) = 1. So (8) holds if £6ti = 1 (modulo to). 

Now if to is not a prime power, let the canonical factorization of to 
into primes be 

m = p^pl 2 ■■■p e r r , (9) 

and for 1 < j < r determine constants bj by the Chinese remainder 
theorem such that 


bj = 1 (modulo p^ 3 ); bj = 0 (modulo p^), k ^ j. (10) 
Then for any integers yi, y 2 , ■ ■ ■ , y r , and y, 

y = yj (modulo p^ 3 ), 1 < j < r, implies y = b ■ y (modulo to). (11) 
It follows that we can write the sum in (7) as 

E , .tlXlH \-t n X nl tiXi 2 -\ btnZn2 , ht„X nr /l o'! 

W 1 W 2 ...U r , (14) 

where uij = ix bi and where the sum is over all sequences of integers 

such that 1 < Xij < p ® 3 and aiXij+a 2 x 2 j 4 t -a n x n j = c (modulo p® 3 ). 

Consequently the sum (12) is S\S 2 ■ ■ ■ S r , where each Sj is a sum like (7) 
for the case to = p® 3 with u>j substituted for w. By (10), tOj is a primitive 
p® 3 th root of unity; so if none of the Sj are zero, we know by the previous 
argument that there exist integers £i, £ 2 , . . . , £ r such that 

(fli, • • • , a n) = .. ,£jt n ) (modulo p® 3 ), 1 <j<r. 

Finally, let £ = 6i£i + b 2 ^ 2 + • ■ • + b r f, r to obtain (8), as desired. □ 


Very Magic Squares 77 

Theorem 2 can be interpreted in the following way: Let us say that 
any sequence of integers aq, a 2 , a n with gcd(ai, a 2 , . . . , a n ) = 1 
determines a family of generalized diagonals, namely the diagonals 
a 1 x 1 +a 2 x 2 -l ba n x n = c (modulo m) for various values of c. The fami- 

lies determined by (cq, . . . , a n ) and (t\, . . . , t n ) are equivalent if (8) holds 
for some £ prime to m; equivalent families are in fact essentially equal. 
Our matrix example above shows the six possible families when m = 5 
and the twelve possible families when m — 6. (The number of families is 
to( 1 +p(( 1 )(l Ppf 1 ) ... (1 -bp" 1 ) when m has the form (9) and n = 2.) 

The content of Theorem 2 is that nonconstant arrays A(x i, . . . , x n ) 
might have constant sums on all generalized diagonals except for those 
in one family. Therefore Theorem 1 is “best possible” in the sense that 
that we cannot prove (2) if we leave any particular family of diagonals 
out of condition (1). 

Since (7) is a system of linear equations in the A(aq, . . . , x n ) with in- 
teger coefficients, and since (6) is a nonzero solution in terms of complex 
values, there must exist integer- valued solutions of (7). For example, the 
6x6 square 

123321 

211233 

332112 (13) 

123321 1 J 

211233 

332112 

is “magic” with respect to each of the 72 possible generalized diagonals, 
except for 4 of the diagonals that belong to the family 2x + by = c 
(modulo 6). 


The preparation of this paper has been supported in part by the National Science 
Foundation. 

References 

[1] Barkley Rosser and R. J. Walker, “The algebraic theory of diabolic 
magic squares,” Duke Mathematical Journal 5 (1939), 705-728. 

[2] A. Renyi, “On projections of probability distributions,” Acta Math- 
ematica Academiae Scientiarum Hungaricse 3 (1952), 131-142. 

[3] John W. Green, “On the determination of a function in the plane 
by its integrals over straight lines,” Proceedings of the American 
Mathematical Society 9 (1958), 758-762. 



Chapter 12 


The Gamow-Stern Elevator Problem 


[Originally published in the Journal of Recreational Mathematics 2 
(1969), 131-137.] 


An amusing mathematical problem was devised by George Gamow and 
Marvin Stern, after they had been somewhat frustrated by the elevator 
service in their office building. Gamow’s office was on the second floor 
and Stern’s on the sixth floor of a seven-story building. Gamow notes 
that, whenever he wished to visit Stern, the first elevator to arrive at 
the second floor was almost always “going down,” not up. It seemed as 
though new elevators were being created at the top floor and destroyed 
at the ground floor, since no elevator ever would bypass the second floor 
intentionally on its way up. But when waiting for a descending elevator 
on the sixth floor, precisely the opposite effect was observed: The first 
elevator to pass was almost always “going up” ! 

Gamow and Stern account for this phenomenon in their enjoyable 
book Puzzle-Math [1, pages 9-10, 59-63], but their explanation is not 
completely valid. It may therefore be of interest to give a correct solution 
to the problem here. 

Preliminary Considerations 

In order to analyze the situation, let us assume that we have an “ideal” 
elevator system, which everyone knows does not exist, but which makes 
it possible to give a reasonable analysis. We will assume that each 
elevator goes continually up and down from the bottom floor to the top 
floor of the building and back again, in a cyclic fashion (independent 
of other elevators) . At the moment we begin to wait for an elevator on 
some given floor of the building, we may assume that each elevator in 
the system is at a random point in its cycle, and that each will proceed 


79 


80 Selected Papers on Fun and Games 
at the same rate of speed until one reaches our floor. Let 
distance from our floor to bottom floor 

p = 

distance from top floor to bottom floor 

be the ratio expressing our percentage distance from the bottom floor. 

The one-elevator problem is easy to solve: If there is only one eleva- 
tor and if we approach it at a random time, there is probability p that it 
is below us (and it will therefore be going up when it next encounters our 
floor), and there is probability 1 —p that is above us (and consequently 
will be going down when we next see it). So if p = 1/6, as in Gamow’s 
case, the next elevator stopping at the second floor will be going down 
five times out of every six. 

The Two-Elevator Problem 

When there is more than one elevator, Gamow and Stern say that “the 
situation will, of course, remain the same.” But that’s not true! Many a 
mathematician has fallen into a similar trap, being misled by something 
that seems self-evident; and nearly every example of faulty reasoning 
that has been published is accompanied by the phrase “of course” or its 
equivalent. 

Let us consider, for example, the two-elevator problem. We may 
assume that p < 1/2; for if p were greater than 1/2 we could consider 
the analogous problem where p is replaced by 1 —p and the directions are 
reversed. Our goal is to compute the probability that the first elevator 
arriving at our floor will be on its way down. 

To solve this problem, we may break it into three cases: 

Case 1, both elevators are above our floor. Then surely the next 
elevator we see will be going down. This case occurs with probability 

(1 -p) 2 . 

Case 2, both elevators are below our floor. Then the next elevator 
we see will be going up. This case occurs with probability p 2 . 

Case 3, one elevator is above us, the other is below. This case occurs 
with probability p( 1 — p) + (1 — p)p = 2p(l — p). Here we might see either 
elevator first, depending on their relative positions. If the upper elevator 
is within distance pD of us, where D is the distance traveled by the 
elevator in each cycle (that is, D is twice the distance from the bottom 
floor to the top floor), we have a 50-50 chance of getting the upper or 
the lower one first; this subcase occurs with probability 2 p 2 . Otherwise 
the lower elevator will arrive first, going up; that subcase occurs with 
probability 2p(l — 2 p). 


The Gamow-Stern Elevator Problem 81 

Summing up, the probability that the first elevator to arrive at our floor 
will be descending is 


(1 - P) 2 ' 1 + P 2 ■ 0 + 2 p 2 • i + 2p(l - 2p) ■ 0 = 1-2 p + 2 p 2 . 

If p = 1/6, for example, the first elevator will be going downward 
with probability 13/18, about 72%. This is somewhat better than the 
83% we had in the one-elevator case, if we want to go up; but it is 
still sufficiently biased against us to make us suspect that some sort of 
conspiracy is causing the elevators to go the wrong way. 

Why is the two-elevator problem different from the one-elevator 
problem? Suppose, for example, that we call the two elevators A and B. 
If we restrict consideration to elevator A, we will find it going down five 
out of every six times when it first arrives; and the same happens if we 
restrict our consideration to elevator B. Furthermore, elevator A will 
be the first to arrive, half of the time, and elevator B will be the first to 
arrive during the other half of the time. So why don’t we get the same 
five-to-six ratio when both elevators are considered? 

The fallacy in this argument is due to a rather subtle failure to 
consider conditional probabilities. (Indeed, Gamow and Stern correctly 
describe several similar fallacies in their book.) The choice of which 
elevator is first to arrive is partly contingent on whether it was above us 
or below us, since an elevator that is below us when we begin to wait is 
more likely to arrive before an elevator that is above us (all other things 
being equal), when p < 1/2. 

The n-Elevator Problem 

Let us now turn to the general situation where there are n independent 
elevators. In this section we will discuss a “brute force” attack on the 
problem. Our solution will involve some interesting elementary interplay 
between discrete mathematics and the infinitesimal calculus; but readers 
who are not especially concerned with such topics may safely ignore the 
following material and skip directly to the “elegant” solution in the next 
section below. 

One way to compute the probability that the next elevator is going 
down is to compute n times the probability that a certain designated 
elevator will be the first to arrive and that it will be going down. If 
the designated elevator reaches our floor, going downward, at time to, 
the desired probability is equal to to minus the time of the previous 
elevator arrival at our floor, measured in units of “elevator cycles.” Since 


82 Selected Papers on Fun and Games 


p < 1/2, one of the undesignated elevators must be the last to arrive 
before time to- 
Let 


m 


ft, if 0 < t < p\ 
\t — p, if p < t < 1. 


If an undesignated elevator reaches our floor going downwards at time 
t 0 — t, where 0 < t < 1, it will reach our floor going upwards at time 
to - t + p; therefore at time t 0 we will have last seen that elevator f(t) 
units of time ago. Consequently, if the n — 1 undesignated elevators 
reach our floor going downwards at the respective times to — t\, to — 12 , 
. . . , t 0 — t n - 1, the amount of time that has elapsed between to and the 
previous elevator arrival is 


min(/(fi), /(t 2 ), ■ • • , /(t n - 1 )) ■ 


To obtain the probability that the designated elevator arrives first on 
our floor at t 0 , if we enter at a random point in time, we now multiply 
this quantity by dti dt 2 ... dt n -i (the differential probability that the 
undesignated elevators arrive at our floor going downwards at respective 
times t 0 - ti, t 0 - t 2 , . . . , t 0 - t„_i), and integrate over 0 < fi < 1, 
0<t 2 < 1, 0< t n - 1 < 1, obtaining the formula 


f f ■ ■ ■[ min(/(ti), f(t 2 ), • ■ ■ ,f(t n -i)) rfin-i ■ • • dt 2 dt-y. 
Jo Jo Jo 


We can evaluate this integral by breaking it into 2" 1 integrals of the 
form 



min(/(fi), f(t 2 ), f(t n - 1 )) df„_ i . 


. dt 2 dt i , 


where each pair (a*, bi) is either (0,p) or {p, 1). For example, when n = 3 
we have 



Each of the latter integrals is simpler to deal with than the original, be- 
cause we may replace f(U) by ti when (a,, bi) = (0,p), and by tj — p when 
( ai,bi ) = (p, 1). By symmetry, we may also permute the pairs ( ai,bi ) 
without changing the value of the integral; and there are ( n ~ k 1 ) integrals 


The Gamow-Stern Elevator Problem 83 


having k of the (a;, bi) equal to ( p , 1 ) and having n — 1 — k of them equal 
to (0 ,p). Hence the original integral reduces to 



A 


n — 1,/e? 


(*) 


where 


m — k 


Am,k — 


rP rp /*! r 1 

/ ... / ... min(fi, . . . , 

Jo Jo J p J p 


tm — ki 

^ra+1 — k P) • • • 5 p) dtm • • • dit\ . 


Replacing tj by tj+pform — k< j < m, we have to evaluate 

m — k k 

/ ^ s / A s 

pp rP pi-p r^-p 

A m ,k= ■•■ / / ■■■ min(ti, . . . , t m ) dt m . . . dt\ . 

Jo Jo Jo Jo 

If 0 < k < m we can break the integration over t m into two parts: 
Over the range 0 to p we get A m ,k- 1 , and over the range p to 1 — p 
we get (1 — 2p)A m -i,k-i, since t m will never be min(£i, . . . ,t m ) when 
t m > p and k < m. Therefore we have the recurrence 


Am,k — — 1 T (1 ‘^p'jAm—l’k—l: for 0 k TTL. 

If k — 0 we have, by definition, 
rp rp 

A m ,o = / •••/ min(t 1 , . . . , t m ) dt m . . . dti, 

Jo Jo 

which (by symmetry) is m\ times the same integral over the region 
0 < t m < • ■ • < t? < ti < p- hence 

rP ft i rtm-l 

Am , 0 TTl\ / / • • • / tm dtm • ■ • dt\. 

Jo Jo Jo 

The latter integral is readily evaluated by induction on m, and we obtain 
A m , o = p m+1 /(m + 1). 

Similarly, 

A m , m = (1 -p) m+1 /(m+ 1). 


84 Selected Papers on Fun and Games 

By induction on k we can now use the recurrence above to find that 


^m,/c — 


/fc\ p m + l 
V 0 / m + 1 



for 0 < k < rri. 


The solution to the n-elevator problem can finally be obtained by 
multiplying (*) by n and carrying out the necessary sums: 


Un- 


n — l.k 


k 


-(>-!>)■ +-e e(”;‘)( 


k<n — 1 j 

n — 1 \ (n — 1 — j\ p 71- - 3 


k<n — 1 j 

(l-p)" + " E (" “ 1 )^(l-2p)’(2- 1 -> - 1) 

j<n J J 

(i-p)" + l^2( n j )(2p) n - j (1^2 P y - ^( n )p"- 3 (l-2p) 3 


k - j > n- j 


) p —Xi-2 P y 

J n — ? 


j<n 


j<n 


= (1 -P)” + Q - ^( 1 - 2 P)") - ((!-?)” - (l-2p)”) 
= | + |d-2 P )^ 


This formula agrees with our earlier calculations when n = 1 or n = 2. 
The simple manipulations of binomial coefficients that are used in this 
derivation are explained, for example, in [2, Section 1.2.6]. 

An “Elegant” Solution 

After all of the involved calculations just made, we have come up with a 
very simple formula, (1 + (l-2p) n )/2, for the “going down” probability. 
In fact, our formula is so simple it suggests that there must be a much 
simpler way to reach the same result. Let us therefore try to see why 
the quantity (1 — 2p) n is meaningful in this problem. 

After some reflection, we can make the following observations: Each 
elevator’s cycle can be represented as a circle of unit circumference, with 
two points separated by an arc of length p to represent the two stops on 


The Gamow-Stern Elevator Problem 85 


our floor. (See Figure 1.) Our problem consists of choosing n points at 
random on the circle, then rotating them synchronously until one point 
hits either the “Going down” or the “Going up” mark. What is the 
probability that we first hit “Going down”? 


Top floor 



Figure 1. 

For an “elegant” solution to this problem, we can mark off another 
arc of length p and divide the circle into three zones, as shown in the 
illustration. If all of the n points fall into Zone A (an event that occurs 
with probability (1 — 2p) n ), then the next elevator to reach our floor will 
obviously be going down. But if one or more of the points fall into 
Zones B or C (an event that occurs with probability 1 — (1 — 2 p) n ), the 
symmetry of the situation shows that there will be a 50-50 chance for 
the next elevator to be going down. Thus the probability is 

(l-2p)" + i(l-(l-2„) n ) = | + |(l-2 p) n , 

just as we derived the hard way. 

Although our calculations so far are valid only when p < 1/2, it is 
not difficult to modify the final formulas so that they are valid for all p 
between 0 and 1: The probability that the first elevator arriving at our 
floor will be going down is, in general, 

i + i(l-2p)|l-2p| n - 1 . 

Notice that this quantity approaches 1/2 as n approaches infinity. 


86 Selected Papers on Fun and Games 

Happiness 

In accordance with this result, let us calculate how many elevators a 
building needs to keep its occupants happy. For convenience, we will 
assume that a person who waits for a descending elevator on the next- 
to-top floor of the building will not be unduly annoyed if the first elevator 
to arrive is going down at least 40% of the time. If the building has m 
floors above its bottom floor, we want to have enough elevators, n, that 

i + i(l-2p)|l-2p| n - 1 >0.4, 

where p — (m — 1 )/m and m > 3. By simple manipulation this relation 
is equivalent to 

n > (log 5)/ (log(l + 2/(m - 2))) = ^(m - 1) + 0(l/m); 

so the number of elevators must be roughly proportional to the number 
of floors! 

The following table shows the dependence of n on m: 


3 4 5 10 20 100 1000 

2 3 4 8 16 80 804 


Acknowledgments 

I wish to thank Peter Weiner for some stimulating discussions of this 
problem, and I also wish to thank the referee for several suggestions 
that improved the presentation in this paper. 

References 

[1] George Gamow and Marvin Stern, Puzzle-Math (New York: Viking 
Press, 1958). 

[2] Donald E. Knuth, Fundamental Algorithms , Volume 1 of The 
Art of Computer Programming (Reading, Massachusetts: Addison- 
Wesley, 1968). 


Chapter 13 

Fibonacci Multiplication 

[Originally published in Applied Mathematics Letters 1 (1988), 57-60.] 

A curious binary operation on the nonnegative integers is shown to be 
associative. 

A well-known theorem of Zeckendorf [1,3,4] states that every nonnega- 
tive integer has a unique representation as a sum of Fibonacci numbers, 
if we stipulate that no two consecutive Fibonacci numbers occur in the 
sum. In other words we can uniquely write 

n = F kr + --- + F k2 +F kl , k r » • • • > k 2 > h » 0, r > 0, (1) 

where the relation “k » j" means that k > j + 2. The Fibonacci 
numbers are defined as usual by the recurrence 

Fo = 0, Fi = 1, F k = F fc _! + F fc _ 2 for k > 2. (2) 

Given the Zeckendorf representations 

m = Fj q -\ F F n , n = F kr + f F kl , (3) 

let us define “circle multiplication” to be the following binary operation: 

q r 

Fj b +k c ■ (4) 

6=1 c=l 

In particular, Fj o F k — Fj +k , if j > 2 and k >2. 

The purpose of this note is to prove that circle multiplication satisfies 
the associative law: 


(Z o m) o n = l o (m o n) . 
87 


(5) 


88 Selected Papers on Fun and Games 

The proof is based on a variant of ordinary radix notation that uses 
Fibonacci numbers instead of powers. Let us write 

( d s . . . dido)p = d s F s + • • • + d\F\ + doFo . (6) 

Then (d s ... dido ) f is a Zeckendorf representation if and only if the 
following three conditions hold: 

Zl. Each digit di is 0 or 1. 

Z2. Each pair of adjacent digits satisfies d*+idj = 0. 

Z3. d\ = do — 0. 

For example, here are the Zeckendorf representations for the numbers 


1 = 

(ioo) F 

9 = (1000100) F 

2 = 

(1000) F 

10 = (1001000) F 

3 = 

(10000)f 

11 = (1010000) F 

4 = 

(10100) F 

12= (1010100) F 

5 = 

( 100000) F 

13 = (10000000) F 

6 = 

(100100) F 

14 = (10000100) F 

7 = 

(101000) F 

15 = (10001000) F 

8 = 

( 1000000) F 

16 = (10010000) F 


Addition of 1 is easy in radix-F: We simply set di <— 1 and do <— 1 
(thereby adding 1 to the value) and then use the “carry” rule 

01 1 -t 100 (7) 

as often as possible until there are no two Is remaining in a row. Finally, 
we set do «— 0. This procedure makes di = 0 after the first carry, so 
conditions (Zl, Z2, Z3) continue to hold. 

In fact, if we begin with any digits ( d s . . .dido)F that satisfy Zl, 
we can systematically apply (7) until both Zl and Z2 are valid. This is 
obvious because the binary value ( d s . . . d x do )2 = 2 s d s + • • • + 2di + do 
increases whenever a carry is performed; therefore the process cannot 
get into a cycle. A given integer has only finitely many representations 
as a sum of positive Fibonacci numbers, so the process must terminate. 

We can also try to add two numbers in radix-F notation, using 
a variant of ordinary binary addition. First we simply add the digits 
without carrying; this gives us digits that are 0, 1, or 2. Then we can 
use the two carry rules 

0 (d+1) (e + 1) — > 1 de 

0 (d+2) 0 e -> 1 dO (e+ 1) 


to restore the conditions Zl and Z2. 


( 8 ) 

( 9 ) 


Fibonacci Multiplication 89 

In fact, we can start with an arbitrary sequence of nonnegative 
digits (d s ... dido) F and systematically propagate carries by using (8) 
and (9), always working as far to the left as possible. Each carry in- 
creases the binary value, so the process must terminate with a final 
configuration (d' t . . . d[d' 0 ) F . Since rule (8) is no longer applicable, we 
must have d( +1 o!( = 0 for all i > 0. Since rule (9) is no longer applicable, 
we must also have d\ < 1 for all i > 2. 

Lemma 1. If d\ = do = 0 and d t < 2 for alii > 2, the carrying process 
just described transforms (d s . . . d 1 d 0 ) F into a sequence (d' t . . . djd' 0 ) F 
that satisfies Z1 and Z2. 

Proof. The result is vacuously true when s < 1. If s > 1, the carrying 
process applied to (d s . . . d 3 0 0) F inductively produces (d' t . . . d' :i d' 2 d' x ) F 
with all d! i < 1; hence the sequence (d s . . . d 3 d 2 dido) F is transformed 
into (d' t . . . d' 3 (d 2 +d' 2 )d[do) F ■ If d 2 + d' 2 < 1 or if d' 3 = 1, further carries 
with (8) will lead to termination without changing d[. Otherwise we 
have d 3 — 0 and 2 < d 2 -\-d' 2 < 3. If d! x = 1, rule (8) clears d \ ; otherwise 
rule (9) sets do 1 and only Os and Is remain. □ 

The addition procedure just described is not complete, however, 
since condition Z3 might not be satisfied. If we can add two numbers 
without “carrying down” into positions di and do, we say that the addi- 
tion is clean. An unclean addition can be finished up by setting d' 0 d[ 
and then carrying if necessary. 

Let n be the smallest subscript, k\, in the Zeckendorf representation 
of n, when n > 0. Thus we have n = ( . . . 1 0 . . . 0)j? , with n zeros after 
the rightmost 1. We also define 0 = oo. 

Lemma 2. If m > 4 and n > 4, the radix-F addition rn + n is clean. 
Moreover, m + n > min(m, n) — 2. 

Proof. Lemma 1 shows that radix-F addition never reduces the num- 
ber of trailing zeros by more than 2. □ 

Circle multiplication m o n has a natural radix-F interpretation, 
because it is completely analogous to ordinary binary multiplication. 
Thus, for example, 


6 o 12 = (100100) F o (1010100) F 
= (10010000) F 
+ (1001000000) F 
+ (100100000000) F 


(10) 


90 Selected Papers on Fun and Games 

because we have j '2 = 5, j\ — 2, k 3 — 6, k 2 = 4, and fci = 2 in the 
notation of (3); the three lines of (10) represent the sums X^b=i Fj b + k c 
for c = 1, 2, 3. These are “partial products” m o F kc . 

Radix- T representation makes it easy to see that circle multiplica- 
tion is monotonic: 

l<m => l o n < m o n, for n > 0. (11) 

For if we increase the left factor by 1, every partial product increases. 

Lemma 3. Radix-F addition of the partial products of mo n is clean. 

Proof. The partial product mo F k has mo F k = m + fc > k + 2. Since 
k r 3> Ay - 1 Ay . we have, successively, 


m o F kr +m o F kr _ 1 > fc r _ x , 
m o F kr + to o F krl + mo F kr _ 2 > Ay_ 2 , 

... mo F kr H 1- m o Ffe 1 > fci , 

by Lemma 2; all of these additions are spanking clean. □ 
Theorem. Let the Zeckendorf representations of l, m, and n be 

^ — Fi p + ■ ■ • + Fi a + Fi i , 

m = Fj q -\ b Fj 2 + F jl , 
n — Fk r + ' • • + F k2 + F kl . 


Then the three-fold circle product is the three-fold sum 

p 1 t 

(lom)on = J2J2J2 F ia +j b +k c - ( 12 ) 

a= 1 6=1 c= 1 

Proof. By Lemma 3, each partial product (/ o m) o F k can be obtained 
by a clean addition of the partial products (/ o Fj) o F k of l o to, shifted 
left k. Hence (lom)oF k = YZ=i EL i F i a+ j b+k , and the result follows 
by summing over k = Ay , . . . , Ay . □ 

Since the sum in (12) is symmetric in l, to, and n, the circle product 
must be associative as claimed in (5). 

We can extend the proof of Lemma 3 without difficulty to show that 
the three- fold addition in (12) is clean. Hence we obtain a similar t-fold 
sum for the t-fold circle product of any t numbers. 


Fibonacci Multiplication 91 

The Fibonacci number F k is asymptotically cj) k /\/Z, where (j> is the 
“golden ratio” (1 + y/Z )/2; hence we have 

FjoF k ~ VZFjFk, as j, k — >• oo. (13) 

It follows that the circle product mon is approximately yfh mn as 2.24mn 
when to and n are large. But 1 o n is closer to as 2.62 n; and 2 o n is 
approximately <(> 3 n « 2.12(2n). 

This paper was inspired by recent work of Porta and Stolarsky [2] , 
who made the remarkable discovery that the more complicated operation 

to * n = mn + [4>m\ [(/)n\ 

is associative. Their “star product” satisfies to * n as 3.62 mn. 

This research was supported in part by National Science Foundation grant CCR-86- 
10181, and in part by Office of Naval Research contract N00014-87-K-0502. 

References 

[1] C. G. Lekkerkerker, “Voorstelling van natuurlijke getallen door een 
som van getallen van Fibonacci,” Simon Stevin 29 (1952), 190-195. 

[2] A. S. Fraenkel, H. Porta, and K. B. Stolarsky, “Some arithmetical 
semigroups,” Progress in Mathematics 85 (1990), 255-264. 

[3] E. Zeckendorf, “Representation des nombres naturels par une 
somme de nombres de Fibonacci ou de nombres de Lucas,” Bulletin 
de la Societe Royale des Sciences de Liege 41 (1972), 179-182. 

[4] E. Zeckendorf, “A generalized Fibonacci numeration,” Fibonacci 
Quarterly 10 (1972), 365-372. 

Addendum 

Zeckendorf’s representation can actually be traced back hundreds of 
years to medieval India, where the anonymous author of Prakrta 
Paingala (c. 1320) presented algorithms for the equivalent problem of 
finding the nth possible rhythm in Sanskrit poetry. Using ‘0’ for a short 
syllable and TO’ for a long syllable, the possibilities are 0, 10, 100, 1000, 
1010, 10000, 10010, etc., preceded by as many 0s as needed to make a 
given total number of beats. 

Yuri Matijasevich wrote to me on 1 May 1990 to point out that he 
had devised the operation mon already in 1967. He called it the indirect 
product in his paper “Two reductions of Hilbert’s tenth problem” [Sem- 
inars in Mathematics, V. A. Steklov Mathematical Institute 8 (1970), 
68-74, which is a translation of his original Russian article in 3a nncKH 
Haynnhix CeMHHapoB JI eimurpajiCKoro O'rpejienmi MaTeMarmecKoro 
IlHCTHTyra HMemi B. A. CreKsiOBti 8 (1968), 145-158]. 


92 Selected Papers on Fun and Games 

Matijasevich had not known that his multiplication is associative; 
he sent me the following elegant algebraic proof of associativity, to com- 
plement the algorithmic proof that I had found: If n has the Zeckendorf 
representation (1), let n = F fcr+1 -| \-F k2+x +F kl+ i be the number ob- 

tained from n by shifting the bits d s . . . d 0 of (6) left one place. Then the 
well-known identity F k +i = F k+1 F t + F fe F)_i = F k+1 F t + F k F i+1 - F k F t 
implies that 

m o n = run + mn — mn. 

Hence (lom)on = (lom)n+(lom)n—(lom)n — (lorh)n-\-{lom)(ji—n) 
id I n + m(ln + In — 2 In) + m(ln — In — In + In) is symmetric in l and n, 
so it must be equal to lo(mon). 

Indeed, if we also let n — n — n denote the operation of shifting n’s 
Zeckendorf representation one place to the right, we discover that 

m o n — rhn — mn = mn + mn + mn ; 
lomon — Imn + lmn — lmn. 

Moreover, n = |_(n + - 1 and n = |_(n + 1)/<AJ- (These Fibonacci- 

shift operations yield surprisingly good ways to convert from miles to 
kilometers or vice versa; see Concrete Mathematics, Section 6.6.) 

Pierre Arnoux [“Some remarks about Fibonacci multiplication,” Ap- 
plied Mathematics Letters 2 (1989), 319-320] observed that, assuming 
Z1-Z3, ( d s . . .dido)p is the Zeckendorf representation of n if and only if 

(d s ... d\do)$ — nfi+n, where (d s ... dido) $ denotes d s (f> s - \ [-dxtfi+do 

(as usual) and <j> — (1 — \Jh)j2 = —l/<p is the other root of the equa- 
tion x 2 = x + 1 satisfied by tj>. These numbers a n all lie in the interval 
1 /4>— 1 < a n < 1 /(j>\ hence the set {a 0 , a 1; a 2 , . . . } is closed under 
multiplication. Thus the rule a m a n — a mon gives a very nice way to 
understand the circle product and why it is associative; that is, 

. 

(mcf) + + n) = (m o n)$ + to q n . 

Generalizations of his results to other numbers 9 instead of <f>, where 6 
is any so-called “Pisot number” (an algebraic integer > 1 whose con- 
jugates all lie inside the unit circle) have been found by P. J. Grabner, 
A. Petho, R. F. Tichy, and G. J. Woeginger, “Associativity of recurrence 
multiplication,” Applied Mathematics Letters 7 (1994), 85-90. 

Note to hackers: If x = (d s . . . did 0 ) 2 corresponds to the Zeckendorf 
representation of n, the following bitwise operations will cleverly convert 
it to the representation of n + 1: 

y <- x | (x » 1), x <- y & ~(y + 4), xi-{x\z) + A. 


i 




Chapter 14 


A Fibonacci-Like Sequence of 
Composite Numbers 


[Originally published in Mathematics Magazine 63 (1990), 21-25.] 


Ronald L. Graham [1] found relatively prime integers a and b such that 
the sequence (Aq, A±, A 2 , . . . ) defined by 

Aq — a , Ai — b , A n — A n _\ + 2 (1) 

contains no prime numbers. His original method proved that the integers 

a = 331635635998274737472200656430763 

( 2 ) 

6= 1510028911088401971189590305498785 

have this property. The purpose of the present note is to show that the 
smaller pair of integers 


a = 62638280004239857 
6 = 49463435743205655 ^ 

also defines such a sequence. 

Let (Fq, Fi, i* 2 , . . . ) be the Fibonacci sequence, defined by (1) with 
a = 0 and 6=1; and let F_ 1 = 1. Then 

A n = F n -ia + F n b . (4) 

Graham’s idea was to find eighteen triples of numbers (pk^mkOk) with 
the properties that 

• pk is prime; 

• F n is divisible by pk if and only if n is divisible by rrik ■ 

• Every integer n is congruent to modulo rrik for some k. 


93 


94 Selected Papers on Fun and Games 
He chose a and b so that 

a = F mk - rk , b = F mk - rk +i (modulo p k ) (5) 

for 1 < k < 18. It followed that 

A n = 0 (modulo pk) n = rk (modulo mk) (6) 

for all n and k. Each A n was consequently divisible by some pk ; it could 
not be prime. 

The eighteen triples in Graham’s construction were 

(3,4,1), (2,3,2), 

(7,8,3), (17,9,4), 

(47,16,7), (19,18,10), 

(2207,32,15), (53,27,16), 

(1087,64,31), (109,27,7), 

(4481,64,63), (5779,54,52), 

(It is easy to check that the second property above holds, because m k is 
the first subscript such that F mk is divisible by pk,. The third property 
holds because the first column nicely “covers” all odd values of n; the 
middle column covers all even n that are not divisible by 6; the third 
column covers all multiples of 6.) It is not difficult to verify by computer 
that the values of a and b in (2) satisfy (5) for all eighteen triples (7); 
therefore, by the Chinese remainder theorem, these values are the small- 
est nonnegative integers that satisfy (5) for 1 < k < 18. Moreover, these 
huge numbers are relatively prime, so they produce a sequence of the 
required type. 

Incidentally, the values of a and b in (2) are not the same as the 34- 
digit values in Graham’s original paper [1]. A minor slip caused his origi- 
nal numbers to be respectively congruent to F 32 and F 33 (mod 1087), not 
to F 33 and F 3 4 , although all the other conditions were satisfied. There- 
fore the sequences defined by his published starting values may contain 
a prime number A. 64 n + 3 i. We are fortunate that calculations with large 
integers are now much simpler than they were in the early 60s when 
Graham originally investigated this problem. 

But we need not use the full strength of (5) to deduce (6). For 
example, if we want 


(5,5,1), 

( 11 , 10 , 2 ), 

(61,15,3), 

(31,30,24), 

(41,20,10), 

(2521,60,60). 


A n = 0 (modulo 3) 


n = 1 (modulo 4) 


A Fibonacci-Like Sequence of Composite Numbers 95 

it is necessary and sufficient to choose a ^ 0 and 6 = 0 (modulo 3); we 
need not stipulate that a = 2 as required by (5). Similarly if we want 

A n = 0 (modulo 17) n = 4 (modulo 9) 

it is necessary and sufficient to have 


A 4 = 0 (modulo 17) and A 5 ± 0 (modulo 17) ; 

the sequence {A 4 , A$, Aq, . . . ) will then be, modulo 17, a nonzero multi- 
ple of the Fibonacci sequence (F 0 ,F 1 ,F 2 ,. . The latter condition can 
also be rewritten in terms of a and 6, 

6 = 5a (modulo 17) and a ^ 0 (modulo 17) , 

because A\ — 2a + 36 and A$ = 3a + 56. This pair of congruences has 16 
times as many solutions as the corresponding relations a = 5 and 6 = 8 
in (5). 

Proceeding in this way, we can recast the desired congruence condi- 
tions (6) in an equivalent form 


b = d k a (modulo p k ) and a^O (modulo p k ) , (8) 

for each of the first seventeen values of k. We choose d k so that 
F rk - i + d k F rk = 0 (modulo p k ) ; 

this can be done since 0 < r k < m k , hence F rk is not a multiple of p k . 
The following pairs ( p k ,d k ) are obtained: 

(3,0), (2,1), (5,0), 

(7.3) , (17,5), (11,10), 

(47.3) , (19,17), (61,30), 

(2207.3) , (53,4), (31,21), 

(1087.3) , (109,100), (41,21), 

(4481,1), (5779,2), (2521,*). 

In each case except the last we have 


F rk + d k F rk+ i 0 (modulo p k ) . 


(Otherwise it would follow that F n +d k F n+ i = 0 for all n and we would 
have a contradiction when n = 0.) 


96 Selected Papers on Fun and Games 

The final case is different, because r is = rrtis- We want 

a = 0 (modulo 2521) and 6^0 (modulo 2521) (9) 

in order to ensure that (6) holds in this case. 

Let us therefore try to find “small” integers a and b that satisfy 
conditions (8) and (9). The first step is to find an integer D such that 

D = dk (modulo pk) (10) 

for 1 < k < 17. Then (8) is equivalent to 

b = aD (modulo P ) and gcd(a, P) = 1 , (11) 

where 


P = p\P2 . . . Pit = 975774869427437100143436645870 . ( 12) 

Such an integer D can be found by using the Chinese remainder algo- 
rithm (see, for example, Knuth [2, Section 4.3.2]); it is 

D = -254801980782455829118669488975 , (13) 

uniquely determined modulo P. 

Our goal is now to find reasonably small positive integers a and b 
such that 

a = 2521n, b = aD mod P , (14) 

for some integer n. If a and b are also relatively prime, we will be done, 
because (8) and (9) will hold. 

Let C = 252 ID mod P. We can solve (14) in principle by trying 
the successive values n = 1, 2, 3, ..., looking for small remainders 
b — nC mod P that occur before the value of a = 2521 n gets too large. 
In practice, we can go faster by using the fact that the smallest values 
of nC mod P can be computed from the continued fraction for C/P (or 
equivalently from the quotients that arise when Euclid’s algorithm is 
used to find the greatest common divisor of C and P). 

Namely, suppose that Euclid’s algorithm produces the quotients and 
remainders 


Po = qiPi + P2 , 

Pi = 92-P2 + P3 , 
P 2 = 93^3 + Pa , 


(15) 


A Fibonacci-Like Sequence of Composite Numbers 97 
when Pq — P and P\ = C . Let us construct the sequence 

n 0 = 1, ni — <7i, n,j — qjrij-i + n,j- 2 . (16) 

Then it is well known (and not difficult to prove from scratch, see 
Knuth [3, exercise 6.4-8]) that the “record-breaking” smallest values 
of nC mod P as n increases, starting at n = 1, are the following: 

n nC mod P 

kn\ + no Pi — kP 2 for 0 < k < q 2 

kn 3 +n 2 P 3 - kP 4 for 0 < k < q 4 

kn 5 + n 4 P 5 - kP 6 for 0 < k < q 6 

and so on. (Notice that when, say, k = q 4 , we have kn 3 + n 2 = n 4 and 
P 2 - kP 4 — P 5 - so the second row of this table overlaps with the case 
k — 0 of the third row. The same overlap occurs between every pair of 
adjacent rows.) In our case we have 

(qi,q 2 ,q 3 ,-..) = (1,2,3,2,1,3,28,1,4, 

1, 1, 1, 6, 12626, 1, 195, 4, 7, 1, 1, 2, ... ) (17) 


and it follows that 

(ni,n 2 , n 3 , . . . ) = (1, 3, 10, 23, 33, 122, 3449, 3571, 17733, . . . ) . 

The record-breaking values of nC mod P begin with 

n nC mod P 

1 679845400109903786358967922355 

2 383915930792370472574499198840 

3 87986461474837158790030475325 

13 56016376581815321375653177785 

23 24046291688793483961275880245 

56 16122498484565130508174462950 

89 8198705280336777055073045655 

122 274912076108423601971628360 

These special values of n increase exponentially as the corresponding 
values of nC mod P decrease exponentially. 

The “best” choice of a = 252 In and b = nC mod P, if we try 
to minimize max(a, b), is obtained when a and b are approximately 
equal. This crossing point occurs among the values n = fcn i7 + ni 6 , 


98 Selected Papers on Fun and Games 
for 0 < k < qis — 7, when we have 


a = 2521n 

b = nC mod P 

gcd {a,b) 

2502466953682069 

237607917830996295 

11 

12525102462108367 

206250504149697855 

1 

22547737970534665 

174893090468399415 

35 

32570373478960963 

143535676787100975 

1 

42593008987387261 

112178263105802535 

17 

52615644495813559 

80820849424504095 

1 

62638280004239857 

49463435743205655 

1 

72660915512666155 

18106022061907215 

5 


We must throw out cases with gcd(a, b) ^ 1, but (luckily) this condition 
doesn’t affect the two values that come nearest each other. The winning 
numbers are the 17-digit values quoted above in (3). 

Slight changes in (7) will probably lead to starting pairs (a, b) that 
are slightly smaller than the 17-digit numbers in (3). But a proof ap- 
plicable to substantially smaller starting values, with say fewer than ten 
digits each, would be quite remarkable. 

This research was supported in part by the National Science Foundation under grant 
CCR-86-10181, and by the Office of Naval Research contract N00014-87-K-0502. 


References 

[1] Ronald L. Graham, “A Fibonacci-like sequence of composite num- 
bers,” Mathematics Magazine 37 (1964), 322-324. 

[2] Donald E. Knuth, Seminumerical Algorithms , Volume 2 of The 
Art of Computer Programming (Reading, Massachusetts: Addison- 
Wesley, 1969). 

[3] Donald E. Knuth, Sorting and Searching, Volume 3 of The Art 
of Computer Programming (Reading, Massachusetts: Addison- 
Wesley, 1973). 

Addendum 

Smaller values of a and b have been found by Herbert S. Wilf [Letter to 
the editor, Mathematics Magazine 63 (1990), 284]; John W. Nicol [“A 
Fibonacci-like sequence of composite numbers,” Electronic Journal of 
Combinatorics 6 (1999), #R44]; and M. Vsemirnov [“A new Fibonacci- 
like sequence of composite numbers,” Journal of Integer Sequences 7 
(2004), article 04.3.7]. The latter article has the currently smallest 
known starting pair: a = 106276436867, b = 35256392432. 


Chapter 15 


Transcendental Numbers Based on the 
Fibonacci Sequence 


[Originally published in Fibonacci Quarterly 2 (1964), 43-44, 52.] 


A well-known theorem due to Liouville [1] states that if £ is an irrational 
algebraic number of degree n, then the inequality 




< 


iii+e 


( 1 ) 


has only finitely many solutions for integers p and q, given any e > 0. 
Therefore, an irrational number £ for which 


i~ P ~ 

q 


< 


( 2 ) 


has solutions for arbitrarily large t must be transcendental. Numbers of 
this type have been called Liouville numbers. 

In 1955, Roth [2] published his celebrated improvement of Liouville’s 
theorem, replacing “n” by “2” in (1). Let us say that an irrational 
number £ is a Roth number if the inequality 


e- 


p 


< 


i 




( 3 ) 


has infinitely many solutions for some e > 0. Roth numbers include not 
only the Liouville numbers but also many more; Roth’s theorem proves 
that all such numbers are transcendental. 

Let b be an integer greater than 1 . Then we define £ b to be the con- 
tinued fraction 

& = L 1 (4) 

hFo , i 


l 


b P 2 


b F 3 


Theorem. The constant £& is a Roth number, so it is transcendental. 

99 


100 Selected Papers on Fun and Games 

Proof. From the elementary theory of continued fractions, it is well 
known that if p n /q n is the nth convergent to then 


I Qn ' QnQn+1 

In the present case, q 0 — 1 , qi = b F ° , and q n +i = b Fn q n + g„_i. We can 
therefore easily verify by induction that 

b F "+ 1 - 1 


In particular, as n — > oo we have q n +i/q n — > b Fn + 2 /b Fn+1 = b Fn 
(( b — l)g n )^ _1 , where <j> = ( 1 + %/5)/2 ~ 1.618. . . is the golden ratio. 
Therefore for large n we have approximately 

( 7 ) 

I q n ^ 

and this completes the proof of the theorem. □ 

Remarks 

It can be easily shown that the set of Roth numbers has measure zero, 
but it is uncountable. For example, the number X^n'Li b~ Cn , where (c n ) 
is a strictly increasing sequence of positive integers, is a Roth number if 
limsup n _ ) . 00 (c n+ i/c n ) > 2, and it is a Liouville number if this limsup is 
infinite. In terms of continued fractions, the number 


is a Roth number if and only if 

log a n 

limsup- > 0, 

n—> oo log qn 

where q n denotes the nth denominator as in the proof of the theorem 
above. 

The rapid convergence of (4) allows us to evaluate £5 easily with 
high precision. For example, 


6 = -70980 34428 61291 31464 17873 99444 57559 70125 . . . ; 
6 = -76859 75605 93155 19850 83724 86230 63473 93713 . . . . 


Transcendental Numbers Based on the Fibonacci Sequence 101 

References 

[1] J. Liouville, “Des classes tres-etendues de quantites dont la valeur 
n’est ni rationnelle ni meme reductible a des irrationnelles alge- 
briques,” Compte Rendu des seances de l’Academie des sciences 
18,20 (15 May 1844), 883-885; “Nouvelle demonstration d’un 
theoreme sur les irrationnelles algebriques,” Compte Rendu des 
seances de lAcademie des sciences 18, 21 (20 May 1844), 910-911; 
“Sur des classes tres-etendues de quantites dont la valeur n’est ni 
algebrique, ni meme reductible a des irrationnelles algebriques,” 
Journal de mathematiques pures et appliquees (1) 16 (1851), 133- 
142. 

[2] K. F. Roth, “Rational approximations to algebraic numbers,” 
Mathematika 2 (1955), 1-20, 168. 

Addendum 

P. E. Bohmer [“Uber die Transzendenz gewisser dyadischer Briiche,” 
Mathematische Annalen 96 (1927), 367-377, 735] published a general 
theorem that implies the surprising identity 

oo 

^ = ( b ~ i) 

n= 1 

although he did not mention this simple case explicitly. In particular, 
we have the binary and ternary representations 

6 = (. 1011010110110101101011011010110110101101 ... ) 2 , 

6 = (. 2022020220220202202022022020220220202202 . . . ) 3 , 

a pattern of zeros and nonzeros known as the infinite Fibonacci word or 
the Fibonacci string S^, which arises in several other contexts. I would 
surely have discovered this property in 1964 if I had had time to com- 
pute the value of £io! [See E. Hecke, “Uber analytische Funkt.ionen und 
die Verteilung von Zahlen mod. eins,” Abhandlungen a us dem Mathe- 
matischen Seminar der Hamburgischen Universitat 1 (1921), 54-76; 
William W. Adams and J. L. Davison, “A remarkable class of con- 
tinued fractions,” Proceedings of the American Mathematical Society 
65 (1977), 194-198; Jean-Paul Allouche and Jeffrey Shallit, Automatic 
Sequences (Cambridge University Press, 2003), §7.1, §9.1, §9.3, §13.6.] 
Notice that £(,/(?> — 1) is a number of the special form b~ Cn 

that I mentioned in the remarks at the close of my short paper, with 
c n = [n^J. It is a Roth number even though lim n ^. 00 (c n _ t _i/c n ) = 1. 





102 Selected Papers on Fun and Games 

Steven R. Finch calls £2 the “rabbit constant” in his book Mathe- 
matical Constants (Cambridge University Press, 2003), §6.8.4. 

At the time I wrote this paper, I was especially interested in knowing 
whether or not the constant 

OO 

£ = 0 . 101001000100001 ... = J^10~ n(n+1)/2 

n = 1 

is transcendental. (Indeed, I had secretly defined the fundamental 
potrzebie constant 

2.26334 845174381732164 73780 749416054791419 51140 . . . 

by laboriously computing the number 900/(3937£); see Chapter 1.) 

My question was finally resolved by Daniel Duverney, Keiji Nishi- 
oka, Kumiko Nishioka, and Iekata Shiokawa [“Transcendence of Jacobi’s 
theta series,” Proceedings of the Japan Academy A72 (1996), 202-203] 
and independently at about the same time by Daniel Bertrand [“Theta 
functions and transcendence,” Ramanujan Journal 1 (1997), 339-350], 
who used results of Yu. V. Nesterenko [«MoAyJinpHwe cjDyHKipHH h 
Bonpocw TpaH cn,e huchtiiocth » , MareMaTUHecKHH C6opmiK 187 A” 9 
(1996), 65-96; “Modular functions and transcendence questions,” Sbor- 
nik: Mathematics 187 (1996), 1319-1348] to prove in fact that the num- 
ber a n ( n+1 ^ is transcendental whenever a is an algebraic number 

between 0 and 1. 


Chapter 16 


Supernatural Numbers 


[Originally published in The Mathematical Gardner, edited by David A. 
Klarner, a festschrift for Martin Gardner on his 65th birthday (Belmont, 
California: Wadsworth, 1981), 310-325.] 

“God,” said Leopold Kronecker [11], “made the integers; everything else 
is the work of man.” If Kronecker was right, it would be heresy to claim 
that any noninteger numbers are supernatural in the sense that they 
have miraculous powers. On the other hand, mathematicians generally 
refer to the nonnegative integers {0, 1, 2, ... } as the set of natural num- 
bers; therefore if any numbers are supernatural, they are also natural. 
The purpose of this essay is to discuss the representation of natural num- 
bers that are “super” in the sense that they are extremely large: Many 
superscripts are needed to express them in conventional notation. 

It doesn’t take a very big number to transcend the size of the known 
universe. For example, if we consider a cube that’s 40 billion light years 
long on each edge, and if we pack that cube with tiny little 10” 13 cm x 
Hr 13 cm x 10- 13 cm cubes (so that each tiny cube is much smaller than 
a proton or neutron), the total number of little cubes is less than 10 125 . 
This quantity isn’t really humongous; it has only 125 digits. 

The great Archimedes seems to have been the first person to discuss 
the existence of extremely large numbers. His famous essay “The sand 
reckoner” [1] concludes by demonstrating that fewer than 10 63 grains of 
sand would be enough to fill the universe as defined in his day. Further- 
more he introduced a system of nomenclature by which he could speak 
of numbers up to i 0 80 . 00 °.ooo, 000 , 000,000 

The English language doesn’t have names for such large quantities, 
and it is instructive to consider how we could provide them systemati- 
cally. In these inflationary days, we may soon need new words to express 
prices; during 1923, for example, Germany issued postage stamps worth 
50 billion marks each, but those stamps were almost valueless. 


103 





When we stop to examine our conventional names for numbers, it 
is immediately apparent that these names are “Menschenwerk” ; they 
could have been designed much better. For example, it would be better 
to forget about thousands entirely, and to make a myriad (10 4 ) the next 
unit after hundreds. After all, numbers like 1984 are conventionally read 
as “nineteen hundred eighty-four,” not as “one thousand nine hundred 
eighty-four.”* The use of myriads would provide us with decent names 
for everything up to 10 8 . For instance, the prime number 9999,9989 
would be called “ninety-nine hundred ninety-nine myriad ninety-nine 
hundred eighty-nine.” 

The next unit we need after myriads is 10 s . Let’s agree to call this 
a myllion (pronounced mile-yun); similar words like myllionaire will, of 
course, also be of use. After myllions come byllions; one byllion equals 
10 16 , the square of a myllion. The unambiguous word byllion for this 
next step is clearly an improvement over present practice, since people 
have never been able to agree about what a “billion” is. (German people 
and some old Englishmen think it is a million million, while Americans 
and some old Frenchmen think it is a thousand million.) Notice also 
the comforting fact that our national debt is only a small fraction of a 
byllion dollars. The nomenclature should now continue as follows: 


10 32 

tryllion 

10 2048 nonyllion 

1Q131072 

quindecyllion 

10 64 

quadryllion 

10 4096 decyllion 

1Q262144 

sexdecyllion 

10 128 

quintyllion 

10 8192 undecyllion 

10524288 

septendecyllion 

1 0 256 

sextyllion 

10 16384 duodecyllion 

101048576 

octodecyllion 

10 512 

septyllion 

lO 32768 tredecyllion 

102097152 

novemdecyllion 

10 1024 

octyllion 

10 65536 quattuor- 

104194304 

vigintyllion 


decyllion 


For example, the total number of ways to shuffle a pack of cards, 52!, is 
the number ‘8065::8175,1709;4387, 8571:6606, 3685;6403,7669;;7528, 9505; 
4408, 8327:7824, 0000;0000, 0000’, if we use punctuation marks to group 
the digits by fours, eights, sixt.eens, and so on. The English name 
for this number under the proposed system would be “eighty hundred 
sixty-five quadryllion eighty-one hundred seventy-five myriad seventeen 
hundred nine myllion forty-three hundred eighty-seven myriad eighty- 
five hundred seventy-one byllion sixty-six hundred six myriad thirty-six 
hundred eighty-five myllion sixty-four hundred three myriad seventy- 
six hundred sixty-nine tryllion seventy-five hundred twenty-eight myriad 


We might also consider changing “nineteen” to “onety-nine,” etc.; but that 
might make our nomenclature too logical. 


Supernatural Numbers 105 

ninety-five hundred five myllion forty-four hundred eight myriad eighty- 
three hundred twenty-seven byllion seventy-eight hundred twenty-four 
myriad myllion. ’ This number is inexpressible in our present American 
language, unless one resorts to something like “eighty thousand six hun- 
dred fifty-eight vigintillion one hundred seventy-five nonillion . . . eight 
hundred twenty-four trillion,” since unabridged dictionaries don’t give 
names for any units bigger than one vigintillion (= 10 63 ) except one 
centillion (= 10 303 ). 

Of course we need to go past vigintyllions and even centyllions if we 
are to have names in our language for all of God’s creation. The next 
unit after vigintyllion presumably should be called “unvigintyllion,” if we 
extrapolate the pattern above and go further in Latin-like nomenclature. 
Thus, from the formula 

80,000,000,000,000,000 = 2 56 + 2 52 -f 2 51 + 2 50 + 2 45 + 2 44 + 2 42 + 2 41 
+ 2 40 + 2 39 + 2 36 + 2 33 + 2 32 + 2 30 + 2 29 + 2 28 + 2 27 + 2 26 + 2 25 + 2 19 , 


a reader who understands the proposed system will know the new name 
of Archimedes’s last number io 80 ’ 000 ’ 000 - 000 ’ 000 -°oo (The answer appears 
at the end of this chapter.) 

Sooner or later we will run out of Latin names to give to the units, 
since Romans never did count very high. Even if Roman scholars had 
adopted Archimedes’s scheme, we would have trouble naming a unit like 

10 80 , 000 , 000 , 000 , 000, 003 

10 2 

But we can get around this problem by simply giving each basic unit 
10 2 "+- the name “latinjthe name of n with spaces deletedjyllion” for all 
large n. For example, i 0 2 — ' °™ 2 would be “latinbyllionyllion.” 
In this way we obtain English names for all the natural numbers, no 
matter how super they are. For example, one of the names would be 
“latinlatinlatinbyllionyllionyllionyllion” ; can the reader deduce its mag- 
nitude? (See the end of this chapter for the answer.) 

At this point the reader may be thinking, “So what? Who cares 
about names for gigantic numbers, when ordinary decimal or binary 
notation gives a simpler representation that is much more suited to cal- 
culations?” Well, it’s quite true that number names are more interesting 
to the linguistic parts of our brains than to the little gray cells that we use 
for calculation; the mere fact that a great man like Archimedes wrote 
about some topic doesn’t necessarily prove that it has any scientific 



106 Selected Papers on Fun and Games 

interest. Our discussion has not been completely pointless, however, be- 
cause it has prepared us to talk about a more important problem whose 
solution involves somewhat similar concepts. 

The problem we shall discuss in the remainder of this chapter is this: 
How can arbitrarily large natural numbers be represented as sequences 
of Os and Is so that the following two properties hold? 

1 The representation of each number is never a “prefix” of the repre- 
sentation of any other number. 

2 The representation of each number should be “lexicographically 
smaller” than the representation of every larger number. 

Condition 1 means that if some number is represented by the sequence 
01101, say, then no other number will have a representation that begins 
with 01101. The notion of “lexicographically smaller” in condition 2 
means “to occur earlier in a dictionary”; thus, for example, 01101 is 
lexicographically smaller than all sequences that begin with 1 or with 
0111 or with 011010 or 011011. 

The importance of this representation problem is that we often want 
to communicate a sequence of numbers to a computer, without putting 
spaces or other separators between consecutive values. Such a sequence 
might, for example, stand for instructions that tell the computer what 
to do. The critical problem is that the computer must know where one 
number stops and the next one begins; condition 1 ensures that this 
will be the case, since the computer can read the sequence from left to 
right and there will be no ambiguity. Condition 2 isn’t quite so critical, 
but it is a nice property to have: It implies that the representation is 
order-preserving in the sense that, whenever one sequence of numbers 
is lexicographically smaller than another, the representation of the first 
sequence will also be lexicographically smaller than the representation 
of the second. 

Conditions 1 and 2 are easy to achieve if we need to represent only 
a few numbers. For example, if we happen to know that only a few 
small numbers will ever be needed, say 0 through 7, we can make all the 
representations of the same length: 000, 001, 010, Oil, 100, 101, 110, 
111. But we want to be able to encode all of the natural numbers, not 
just the small ones. 

Perhaps the first correct solution that comes to mind is a “unary” 
scheme, where we represent 0 as ‘O’, 1 as TO’, 2 as T10’, and so forth; the 
representation of n is T n 0’, that is, n ones followed by a single zero. The 
zero acts as an end-marker or “comma” between successive numbers that 
the computer must read. This representation clearly satisfies 1 and 2; 


Supernatural Numbers 107 

but it is hardly a practical way to represent numbers that are moderately 
large, and it’s horrible in the really big cases, because it requires n + 1 
bits to represent n. We really want to have a representation that is as 
concise as possible, subjection to conditions 1 and 2. 

Perhaps the next simplest solution is based on the ordinary binary 
notation for integers, namely {0, 1, 10, 11, 100, 101, ... }. This represen- 
tation as it stands doesn’t satisfy either 1 or 2; but we can beef it up 
by prefixing the binary notation by a suitable sequence to indicate the 
length, as follows: 


0 i-4 00 

8 t-4 1110000 

1 i-4 01 

9 1-4 1110001 

2 >-4 100 

10 H4 1110010 

3 i-4 101 

15 1-4 1110111 

4 i-4 11000 

16 H4 111100000 

5 11001 

31 H4 111101111 

6 i-4 11010 

32 H4 11111000000 

7e4 11011 

63 i-4 11111011111 


64 i-4 1111110000000 

127 1-4 1111110111111 

128 i-4 111111100000000 

255 i ^ 111111101111111 

256 i-4 11111111000000000 

511 i-4 11111111011111111 

512 i-4 1111111110000000000 

1000 i ^ 1111111110111101000 


In general for n > 2, if the binary representation of n is (la )2 where a 
is any sequence of 0s and Is, the new representation of n is 


l |Q| 0a 


where |a| denotes the length of a. If m bits are needed to write n in 
binary notation, where m > 1, the new representation has 2m — 1 bits. 
We have roughly doubled the number of bits needed to represent n, in 
order to indicate unambiguously where each representation ends. 

This solution can be improved, but before we pursue the investi- 
gation any further it is interesting to point out that our problem is 
essentially equivalent to a guessing game , where one person has thought 
of an arbitrary natural number and the other person tries to guess it. 
The rules of this game are something like Twenty Questions: The one 
who guesses is only allowed to ask “Is your number less than g?” for 
nonnegative integers g , and the opponent answers “yes” or “no.” The 
game might last longer than twenty questions, because infinitely many 
secret numbers are allowed; there’s no way to distinguish between more 
than 2 20 numbers based on the answers to only 20 yes-no questions. But 
the general idea is to guess the number as quickly as possible. 

The relation between this guessing game and the sequence represen- 
tation problem is not difficult to see. Any fixed strategy that can be 
used by the guesser to deduce all natural numbers leads to a solution to 


108 Selected Papers on Fun and Games 

1 and 2: We simply let the representation of n be the sequence of an- 
swers that would be given when the secret number is n, with 0 standing 
for “yes” and 1 for “no.” Conversely, given a solution to 1 and 2, we 
can construct a guessing strategy that corresponds to it under this rule, 
if we also allow the guesser to ask the stupid question “Is your number 
less than infinity?” (The answer to that question will always be “yes”; 
some solutions to 1 and 2 have every representation beginning with 0.) 

The unary solution that we discussed first corresponds to the strat- 
egy under which the guesser simply asks 

Is your number less than 1? 

Is your number less than 2? 

Is your number less than 3? 

and so on, until receiving the first “yes.” Our second solution is more 
clever: It begins with the questions 

Is your number less than 2? 

Is your number less than 4? 

Is your number less than 8? 

and so on; then it uses a “binary search” to pinpoint the secret number 
once the first “yes” answer has revealed its order of magnitude. 

Under this equivalence between the guessing game and the represen- 
tation problem, a good strategy for the guesser corresponds to a concise 
representation for numbers. So our search for good representations boils 
down to the same thing as the search for a good number-guessing scheme. 

Incidentally, the number-guessing game isn’t just frivolous; it has 
important practical applications. For example, if a continuous function 
f(x) is known to have exactly one positive root, where /( 0) is negative 
and f(x) is positive for all sufficiently large x, the root is less than g if and 
only if f(g) is positive. Thus a good strategy for number guessing leads 
to an efficient procedure for root location without evaluating derivatives 
of /. 

We can improve on the second solution above by realizing that it 
is essentially using the unary strategy to represent the length of n’s 
binary representation; the binary strategy can be substituted instead! 
In other words, the sequence 1 1“! 0 used to encode the length of a can 
be replaced by a more concise representation of |a|. By using this idea 
repeatedly, we obtain progressively shorter and shorter representations 
for large numbers. And we are eventually led to what might be called 
a recursive strategy, of the following form: “First guess the number of 


Supernatural Numbers 109 

binary digits of n, then use binary search to determine the exact value.” 
To guess the number of digits of n, the same strategy is to be used, 
recursively; thus we first guess the number of digits in the number of 
digits of n, by guessing the number of digits in the number of digits in 
the number of digits of n, et cetera. The first questions in the recursive 
strategy are: 

Is your number less than 1? 

Is your number less than 2? 

Is your number less than 4? 

Is your number less than 16? 

Is your number less than 65536? 

and so on, until the answer is “yes.” (Notice that 2 = 2 1 , 4 = 2 2 , 16 = 2 4 , 
and 65536 = 2 16 ; the next question would refer to 2 65536 , and the next 
would refer to 2 that .) Eventually this recursive strategy finds an upper 
bound on the secret number; then it proceeds to unwind the recursion. 
If the secret number is really enormous, the guesser will soon be guessing 
really enormous values. 

The recursive representation corresponding to this recursive guessing 
scheme can be defined very simply: Let R(n ) be the sequence of Os and 
Is that represents n. Then 


R{ 0) = 0; and R{{la) 2 ) = lR(\a\)a. 


Small integers are represented as follows: 


0e>0 

8 11101000 

64 i ^ 

1 10 

9 i ^ 11101001 

127 ^ 

2 i y 1100 

10 >-4 11101010 

128 M. 

3 (-4 1101 

15 >-4 11101111 

255 h-> 

4 H- 1110000 

16 i ^ 111100000000 

256 h-> 

5 n- 1110001 

31 111100001111 

511 h4 

6 >-4 1110010 

32 >-4 1111000100000 

512 >-4 

7 >-> 1110011 

63 1111000111111 

1000 i-4 


11110010000000 

11110010111111 

111100110000000 

111100111111111 

11110100000000000 

11110100011111111 

111101001000000000 

111101001111101000 


It’s easy to see that this representation satisfies 1 and 2 . Computer 
scientists interested in the transformation of recursive methods to iter- 


ative methods will enjoy finding a simple nonrecursive procedure that 
evaluates n, given its representation; a solution appears at the end of 
this chapter. 

The recursive representation of a large number n will be about half 
as long as its representation under the binary scheme. For example, the 
representation of 2 65536 - 1 in the binary scheme is the sequence 


^65535q^65535 


110 Selected Papers on Fun and Games 

of length 131071, while its representation in the recursive scheme is 

15q ^65554 


only 65560 bits long. On the other hand, the recursive scheme takes 
quite awhile to show any payoff when we examine its encodings of small 
numbers; the binary scheme produces a representation that is shorter 
than the recursive one for all values of n between 2 and 127 inclusive! 
(The recursive scheme wins out only when n = 0 or when n is 512 or 
more.) Thus the binary scheme will be preferable in many applications. 

We can improve the recursive scheme’s performance for small n by 
observing that all sequences except for the sequence representing 0 begin 
with 1; if we only want to represent strictly positive numbers, we can 
safely drop the initial T’. Furthermore the natural numbers are in one- 
to-one correspondence with the strictly positive integers, so there is a 
representation Q(n ) such that 

1 Q(n) — R(n + 1). 

Under this modified recursive scheme we have 

0 H> 0 

1 i — ¥ 100 

2 i-> 101 

3 i ^ 110000 
4 h-> 110001 

and so on; the binary scheme beats this one only for n = 1, 3, 4, 5, 6, 
7, and for 15 < n < 63. The same transformation can be applied to the 
Q scheme, for the same reasons, yielding a P scheme where 

1 P(n) = Q(n + 1), 


so that we have 


0 t-4 00 

1 01 

2 i — ^ 10000 

3 10001 

4 10010 


etc.; now the binary scheme wins only for 24 values of n. 

In some sense we would like to find the best possible strategy, but it 
is hard to say exactly what that means. The binary strategy looks a lot 
better than the unary one, but even the unary strategy beats the binary 


Supernatural Numbers 111 

scheme when n = 0. We will see below that this situation is inevitable: 
No strategy for the guessing game can completely dominate another — 
in the sense that the first needs no more questions than the second does 
to determine n, for all n, and the first sometimes even gets by with fewer 
questions — unless, of course, the dominated strategy asks stupid ques- 
tions whose answer “yes” or “no” is already deducible from the previous 
answers. If one nonstupid strategy is better than another, for some n, 
it will necessarily be worse for others. You win some, you lose some. 

In order to analyze just how good these schemes are, we ought to be 
more quantitative. (Let the reader beware: The rest of this chapter in- 
volves mathematical technicalities that are elementary but sometimes a 
bit subtle.) If n > 1, let us write An for the unique natural number such 
that 2 An < n < 2 1+An . Thus if n — (la )2 in binary notation, the num- 
ber An is |a|, the length of a. It is convenient to define AO = 0, so that 
An is a natural number whenever n is a natural number. We shall write 
AAn for A(An), and so on; furthermore A m n will stand for the m-fold rep- 
etition of the A function, so that A°n = n and A 3 n = AAA n, etc. Finally, 
we also write A*n, to denote the least integer m such that A m n = 0. 

It is easy to express the length of various representations of n in 
terms of such functions. Let c(n) be this length, that is, the “cost” of 
representing n. In the guessing game, c(n) is the number of questions 
needed to determine a given secret number. The unary guessing strategy 
has a rather large cost, 

cu{n) = n + 1, 

while the binary strategy reduces this to 


c B (n) 


f 2, if n = 0 or n = 1; 

[ 2A n +1, if n > 1. 


The cost of the recursive strategy is 

= An Y AAn Y AAA n Y * * * Y A *n Y 1, 

where the infinite series implied by the • • • is really finite, since A m n — 0 
whenever m > A*n. Finally, the modified recursive strategies have costs 

c Q (n) = c R (n Y 1) - 1, cp(n) = c fi (nY2)-2. 

These formulas verify our remark that the recursive strategies cost about 
half as much as the binary scheme when n is large. 


112 Selected Papers on Fun and Games 

Let us say that a representation scheme is irredundant if the corre- 
sponding guessing game never asks any questions that are “stupid” as 
discussed earlier. Irredundant schemes have the following property: If 
a is any sequence of Os and Is such that a occurs as a prefix of some 
representation of an integer, but a is not itself the entire representation 
of any n, then both ctO and al occur as prefixes of representations. 

All reasonable schemes are irredundant. For if, say, aO occurs as a 
prefix but al doesn’t, we can shorten the representation of some integers 
without violating 1 or 2 merely by deleting the 0 following a whenever 
a appears as a prefix. 

The cost functions of irredundant representations satisfy an impor- 
tant arithmetical relation: 

Fact 1 . Let c(n) be the cost of representing n in an irredundant repre- 
sentation scheme. Then 

1 1 1 

2 c (o) + 2 C ( 1 ) + 2 C ( 2 ) + '" ‘ 


Proof. In fact, if a is the representation of n, we have 


1 1 1 

2 C (°) ^ 2 C ( 1 ) 2 c ( n_1 l 


0)2 


(*) 


in binary notation, for all n. This formula clearly holds when n = 0 , 
since there can be no Is in an irredundant representation of 0 . Let f 3 be 
the representation of n + 1; we need to show that 


(•“) 2 + ^h - (^) 2 - 


No number is represented by a sequence of Is only, since the se- 
quence l m is followed in lexicographic order only by sequences of which 
it is a prefix. Thus (.a) 2 + 2 ~M = (.010203 . . . ) 2 is the smallest bi- 
nary fraction greater than (.a) 2 that doesn’t have a as a prefix. If 
(,/ 3 ) 2 = (.6i6 2 6 3 . . • ) 2 is unequal to (.aia 2 a 3 . . . ) 2 , let j be minimal such 
that bj / aj and let k be maximal such that = 1 . Notice that k is 
the position of the rightmost 0 in a. 

We have (.616263 . . . ) 2 > (.aia 2 a 3 . . . ) 2 ; hence bj = 1 and aj = 0 . If 
k < j, the sequence 61 . . . 6j_i is a redundant prefix, because 61 . . . 6^ _ 1 1 
occurs as a prefix of the representation of n + 1 but 61 . . . 6j_i0 never 
occurs as a prefix. If k > j, the sequence a±...ak-i is a redundant 
prefix, because ai . . . Ofe_i0 occurs as a prefix of the representation of n 


Supernatural Numbers 113 

but ax . . . a fc _x 1 never occurs as a prefix. But k cannot equal j, since 
dfc = 1. This contradiction proves (*), by induction on n. 

The irredundancy condition implies that l m occurs as a prefix for 
all to. Now if 1 TO is a prefix of the representation of n, the sum 2 _c (°) + 

2 c ( x ) + 1- 2 -c ( n-1) lies between (.l m ) 2 = 1 — 2 -m and 1; hence the 

infinite sum as n oo converges to 1. □ 

(This proof uses both properties 1 and 2, and indeed the result 
would be false if only property 1 were assumed. For example, the follow- 
ing procedure generates representations of length n + k for each integer 
n > 0 in an irredundant fashion, for any fixed k > 2: Represent 0 by 0 fc . 
Then for n = 1, 2, 3, ... , find a sequence a such that (a) a has occurred 
as a prefix of a representation for some number less than n but not as 
a representation; (b) aO and al have not both occurred as prefixes; and 
(c) a is as short as possible satisfying (a) and (b). The representation 
of n can be any sequence of length n + k that contains aO or al as a 
prefix, whichever hasn’t previously occurred. One such representation 
scheme for k = 2 begins 

0h-> 00 3 h- >■ 11000 6 11100000 

1 100 4 m- 011000 7 < — ^ 010100000 

2 0100 5 ^ 1010000 8 0111000000. 

On the other hand, it is not difficult to prove the inequality 

111 

2 C (°) + 2 C ( 1 ) + 2 c ( 2 ) + “ 1 

for all representations that satisfy property 1; this relation is known as 
“Kraft’s inequality” [10].) 

There is also a converse to Fact 1: 

Fact 2. Let c(0), c(l), c(2), ... be a nondecreasing sequence of positive 
integers such that 


1 1 1 

2 C (°) + 2 C ( 1 > + 2 c O) 4 ~ L 

Then there is an irredundant representation scheme with cost func- 
tion c(n). 

Proof. We obtain a scheme with the desired properties by letting the 
representation a of n be defined by (*) and |a| = c(n). □ 


114 Selected Papers on Fun and Games 

If X is an irredundant representation scheme whose cost function 
cx is not monotonic, we can permute the integers to obtain another 
representation with the same costs sorted into nondecreasing order. 
Facts 1 and 2 now show that there exists an irredundant scheme hav- 
ing these sorted costs. Representation schemes with monotonic cost 
functions can be called standard, since most applications prefer to have 
cx{n) < Cx(n + 1) for all n. 

Let us conclude our investigations by trying to find the best possible 
scheme, putting an emphasis on asymptotic questions (that is, on the 
efficient representation of very very large integers). Clearly the binary 
method is more efficient than the unary method, and we also prefer the 
recursive method to the binary method because of its superior perfor- 
mance when n is large. These examples suggest the following definition: 
“A representation scheme Y with cost function cy[n ) dominates an- 
other scheme X with cost function cx(n) if we have cy(n) < cx{n) for 
all large n and cy(n) < cx[n) for infinitely many n.” If Y dominates X 
and Z dominates Y by this definition, then Z dominates X . 

Clearly the recursive methods P, Q, R all dominate the binary 
method B, and B dominates the unary method U . When we try to 
compare the three recursive schemes with each other, however, it turns 
out that none of them is dominant. Method P is best nearly all the time; 
in particular, whenever An = A (n + 2) we have cp(n) — cq(ti) — 1 = 
Cfl(n) — 2. But there are infinitely many n where Q is better than both 
P and R (namely when n = 2 2 — 2 and k > 1); and there are in- 
finitely many n where R is better than both P and Q (namely when 
n = 2 22 — 1). These facts suggest that it might be impossible to domi- 
nate method R, and in that sense we might conclude that method R is 
“optimal.” However, any such hopes are quashed by 

Fact 3. If X is any standard representation scheme, there is an- 
other standard representation scheme Y that dominates X and satisfies 
cy(n) < Cx(n) for all but one value of n. 

Proof. The general idea of the proof is to choose a binary sequence a of 
length c and replace it by infinitely many sequences, of respective lengths 
c + 1, c + 2, c + 3, etc., because 2~ c = 2 _c_1 + 2 -c-2 + 2~ c ~ 3 + • • • . 

Proceeding more formally, we may assume that X is irredundant. 
For k > 1 let be the number of n’s such that cx{n) = k, and let j = 
cx(0). Let bk = 0 for 1 < k < j, bj — aj — 1, and b^ — + 1 for k > j. 

Then there is a unique nondecreasing function cy(n) having exactly 
bk values of n with cy{n ) = k; and this function satisfies 2 ~ C¥ + 
2 “ c v(i) 2 -c *(°) -f 2 _cx(1 ) + • • ■ . By Fact 1 and Fact 2, there is 


Supernatural Numbers 115 

an irredundant standard representation scheme with cost function cy. 
Furthermore we easily see that cy (n) < Cx(n ) except for the single value 
of n such that cx{n) = j and cx(n + 1) > j; and we have cy(n) < cx{n) 
whenever j + 1 < c x (n - 1) < c x {n). □ 

It is hopeless to find a strictly optimum scheme, because repeated 
application of the construction in the proof of Fact 3 will give an infinite 
family of better and better schemes, each dominating its predecessors. 
However, no scheme can actually be much better than our recursive 
scheme R, in spite of all the apparent improvement guaranteed by Fact 3. 

Fact 4. Let An be the function defined by 

An — A n T XXn T AAA n -F • * • . 


Every cost function c(n) that corresponds to a representation scheme 
satisfies 

c(n ) > An + AA*n 

for infinitely many n. 

Proof. Let d(n ) = An + XX* n; we shall show that the sum 2 -d (”) 

diverges. This will suffice to complete the proof, for if the cost function 
could satisfy c(n) < d(n) for all n > m we would have the impossible 
inequality 

oo m— 1 oo 

i = ^ - 2 ~ d( ' n ' > ) + 2 ~ d( - n '> . 

n= 0 n= 0 n=0 

In general if /(n) = An + g{X*n) for any function g , we have the (rather 
amazing) identity 


(-XJ 1 OO 1 

= V — 

o/(n) o g(n) ’ 


since the left-hand side can be written 


00 1 i 

V — E V — 

Z—/ o g(m) / ^ oAr. 


Z—/ 2 P( m ) ' v 2 Ari 
m = 0 A *n=m 


and for to > 1 we have 


v J_ = v 

Z / O An / ^ 


A * Xn=m— 1 


2 An+AAn 


= E 


/ j 2 fc + Afc ^ 
\*k=m — 1 Xn=k 


= y — 

/ ^ o A/c 


Thus the sum XX>o 2 diverges if and only if the sum X] n >o 2 Xn 
diverges. And it does. □ 


116 Selected Papers on Fun and Games 

Using the same proof technique, we can show in fact that 
c(n) > An + AA*n + AX* X*n + ■ • • + A(A*) m n + A(A*) m+1 n 
infinitely often, for any fixed representation scheme and any fixed m. 

Let us close by showing how to improve scheme R so that we obtain 
“ultimate” schemes that come very close to this lower bound. The se- 
quence R(n) begins with 1 A n 0, a sequence of length \*n + 1 that serves 
to identify A *n, followed by a sequence of length An that characterizes n 
once \*n is known. In this sense, the R method starts by using a unary 
approach to guess A*n; and we know that we can do better. Let us 
therefore use the R method to determine A *n, then continue to deter- 
mine n as before, calling this the RR method. The new cost function 

crr(u) — An + cr{\* n) = An + AA*n + A* A*n + 1, 

and the RR representation of n will begin with the sequence 1 A A n 0. 

But wait; let’s start by guessing A*A *n. Then we obtain an RRR 
method whose cost function is 

crrr{u) - An + AA *n + c R (\*\*n) 

= An + AA *n + A\*X*n + X*X*X*n + 1. 

The R m+1 method has a cost function equal to 

c(n) = An + AA*n + ■ • • + A(A*) m n + (A*) m+1 n + 1, 
and this upper bound is almost the same as our lower bound. 

Related Work 

Philip Davis [5] has written a delightful introduction to the elementary 
facts about large numbers. 

An ancient Chinese mathematician named Hsu Yo, about A.D. 200, 
discussed a nomenclature for large numbers containing the units wan — 
10 4 , i = 10 s , chao — 10 16 , and ching = 10 32 , in his interesting book Shu 
Shu Chi I ; see [13, page 87]. I am indebted to Tung Yun-Mei for this 
reference. 

The representation scheme B with c(n) ps 2An was published by Stig 
Comet in [4] . The problem of representation schemes in general was in- 
troduced by Levenshtein [12], who presented method R and proved that 
c(n) > An — X*n for infinitely many n; he also discussed representa- 
tions with more than two symbols. The representation problem has also 
been studied independently by Elias [6] and by Even and Rodeh [7], 
The guessing game for unbounded search was suggested by Bentley and 
Yao [2], Methods P and Q were proposed by Jim Boyce and David 
Fuchs during a recent conversation with the author. 


Supernatural Numbers 117 

Numbers much larger than those considered here are discussed in [9]. 
Using the notation of that article, we have A* (2 tt m ) — m + 1 and 
A* (2 ttt m ) — (2 ttt ( m — 1)) + 1, suggesting that the upper and 
lower bounds we have derived are really not so close together after all. 
Perhaps the introduction of functions A **n and A***n, etc., will lead 
to further clarification of “optimum” representation schemes when we 
imagine ourselves dealing with supersupernatural numbers. 

There is a beautiful connection between the concepts we’ve discussed 
and the information-theoretic concept of algorithmic complexity, orig- 
inated independently by L. A. Levin in Russia and G. J. Chait.in in 
Argentina. A certain function Z(n), called KP(n) by Levin (see [8]) and 
H(n) by Chaitin [3], has the following two properties: (a) There is a 
representation scheme for natural numbers that satisfies condition 1 and 
has cost l(n). (b) For every representation scheme satisfying condition 1 
and having cost c(n), there is a constant C such that l(n) < c(n) + C. 
Intuitively, l(n) represents the length of the “simplest” description of 
an algorithm to compute n. This function l(n ) is not computable, 
but it is sernicomputable from above, in the sense that, if l(n) is ac- 
tually less than a given number m, we can prove this fact in a finite 
amount of time. If c(n) is the cost function for any representation 
scheme that satisfies conditions 1 and 2, there is a constant C such 
that A n + l(Xn) < c(n) + C. Furthermore there is a constant Co such 
that | An + Z(An) — maxi<fc<„ f(&) | < Co- Thus the constructions we have 
given provide bounds on maxi <k< n l{k). I am indebted to Peter Gacs 
for these references. 

References 

[1] Archimedes, “The sand reckoner,” in The World of Mathematics 1 , 
edited by James R. Newman (New York: Simon and Schuster, 1956), 
420-429. 

[2] John Louis Bentley and Andrew Chi-Chih Yao, “An almost opti- 
mal algorithm for unbounded searching,” Information Processing 
Letters 5 (1976), 82-87. 

[3] Gregory J. Chaitin, “A theory of program size formally identical 
to information theory,” Journal of the Association for Computing 
Machinery 22 (1975), 329-340. 

[4] Stig Comet, “Notations for partitions,” Mathematical Tables and 
Other Aids to Computation 9 (1955), 143-146. 

[5] Philip J. Davis, The Lore of Large Numbers (New York: Random 
House, 1961). [Volume 6 of the New Mathematical Library .] 


118 Selected Papers on Fun and Games 

[6] Peter Elias, “Universal codeword sets and representations of the 
integers,” IEEE Transactions on Information Theory IT-21 (1975), 
194-203. 

[7] S. Even and M. Rodeh, “Economical encoding of commas between 
strings,” Communications of the ACM 21 (1978), 315-317. 

[8] Peter Gacs, “On the symmetry of algorithmic information,” So- 
viet Mathematics Dokla dy 15,5 (1974), 1477 1480; 15,6 (1974), v. 
[Translation of II. Tan, «0 CHMMeTpnuM a ji r o p m t m n ho c k o u hh- 
<f)opMamin», JJ,oKap,bi Anajj,CMmi HayK CCCP 218 (1974), 1265- 
1267.] 

[9] Donald E. Knuth, “Mathematics and computer science: Coping 
with finiteness,” Science 194 (1976), 1235-1242. [Reprinted as 
Chapter 2 of Selected Papers on Computer Science, CSLI Lecture 
Notes 59 (Stanford, California: Center for the Study of Language 
and Information, 1996), 31-58.] 

[10] Leon G. Kraft, Jr., “A device for quantizing, grouping, and coding 
amplitude-modulated pulses,” M.S. thesis in Electrical Engineering 
(Cambridge, Massachusetts: Massachusetts Institute of Technology, 
1949), 62 pages. 

[11] L. Kronecker, remark in a lecture at the Berlin scientific congress 
(1886): “Die ganzen Zahlen hat der liebe Gott gemacht, alles andere 
ist Menschenwerk.” Quoted by H. Weber, Mathematische Annalen 
43 (1893), 15. 

[12] V. I. Levenshtein, “On the redundancy and delay of decodable cod- 
ing of natural numbers,” Systems Theory Research 20 (1968), 149- 
155. [Translation of B. H. JleBemiiTeHH, <<06 h36bitohhocth h 
3aMeAJieHHH par-sflejimvioro KOAupoBauua HaTypajibHbix unceji», 
TIpo6jieMbi KudepHeTHKH 20 (1968), 173-179.] 

[13] Joseph Needham, Science and Civilization in China 3 (Cambridge: 
Cambridge University Press, 1959). 

Solutions 

1 Archimedes’s last number: One septendecyllion trevigintyllion 
quattuorvigintyllion quinvigintyllion sexvigintyllion septenvigintyllion 
octovigintyllion trigintyllion untrigintyllion quattuortrigintyllion septen- 
trigintyllion octotrigintyllion novemtrigintyllion quadragintyllion duo- 
quadragintyllion trequadragintyllion octoquadragintyllion novem- 
quadragintyllion quinquagintyllion quattuorquinquagintyllion. (His own 


Supernatural Numbers 119 

name for this number was much shorter, but the new system beats his 
in lots of other cases.) 

Incidentally, American names for large numbers are not based on 
good Latin (sexdecillion should be “sedecillion” and novemdecillion 
should be “undevigintillion”); so it isn’t clear how much further the 
American system can be extrapolated. See Dmitri A. Borgmann, “N am - 
ing the numbers” and “Renaming the numbers,” Word Ways 1 (1968), 
28-31, 89-93, for proposals by Rudolf Ondrejka; see also John Cande- 
laria, “Extending the number names,” Word Ways 8 (1975), 141-142; 
“Renaming the extended numbers,” Word Ways 9 (1976), 39; “A new 
number nomenclature,” Word Ways 16 (1983), 125-127; A. Ross Eckler, 
“The only man infinity fears,” Word Ways 19 (1986), 252-254. More 
recent proposals have been made by John H. Conway, Richard K. Guy, 
and Allan Wechsler, on pages 13-16 of Conway and Guy’s The Book of 
Numbers (New York: Copernicus, 1996). 

2 One latinlatinlatinbyllionyllionyllionyllion is 


10 


9 10000000000000002 
, 10 J +21 

2 (10 2 ' T ' + 2) 


We might call this one umptyllion, for short. 

3 An iterative decoding procedure for method R: Let the input se- 
quence be S1S2S3 . . . , where each Si is 0 or 1. Let k be the number of 
input bits already read; let l be the length of a number to be input; let 
m be the stack depth in a recursive implementation; and let n be the 
answer returned. The following recursive method corresponds directly 
to the definition, with k initially zero, using only global variables: 
Procedure R. 

Set k 4 — k J- 1. 

If Sfc = 0, set n 4— 0 and exit from R. 

Otherwise call R (recursively). 

Then set l 4 — n and n <— 1. 

While l > 0, repeatedly set k <— k + 1, n «— 2n + s*., l 4 — l — 1. 

Exit from R. 

The recursive program above can be transformed mechanically into the 
following purely iterative procedure: 

Set k 4 — 1 and m 4— 0. 

While Sk — 1, repeatedly set m 4 - m + 1 and k 4- k + 1. 

Set n 4 — 0. 

While to > 0, repeatedly do the following operations: 


120 Selected Papers on Fun and Games 

Set m <— m — 1, l <— n, n t— 1. 

While l > 0, repeatedly set k «— k + 1, n <— 2n + Sfc, l 4— l — 1. 
The corresponding encoding procedure can be treated similarly. 

Addendum 

When I was asked in 1978 to write something for Martin Gardner’s 65th 
birthday, I chose the title “Supernatural numbers” as a sort of counter- 
point to my novelette about Surreal Numbers (Reading, Massachusetts: 
Addison- Wesley, 1974), with which Martin was quite familiar. I had no 
idea that many mathematicians were already using the term ‘supernatu- 
ral numbers’ in a serious way, to stand for the multiplicative extension of 
positive integers that consists of all possible products — finite or count- 
ably infinite — of prime numbers. [See, for example, Stephen S. Shatz, 
ProHnite Groups, Arithmetic, and Geometry, Annals of Mathematics 
Studies 67 (Princeton, New Jersey: Princeton University Press, 1972), 
12.] That concept had been introduced by Ernst Steinitz in section 16 
of his classic paper “Algebraische Theorie der Korper,” Journal fur die 
reine und angewandte Mathematik 137 (1910), 167-309, under the name 
G-Zahlen (Gradzahlen). Jean-Pierre Serre called them the ‘nombres sur- 
naturel’ in section 1.1.3 of his book Cohomologie Galoisienne [ Lecture 
Notes in Mathematics 5 (1964)], and his name for them has become 
standard terminology. Such numbers, the “real” supernatural numbers, 
continue to find more and more uses as mathematics advances. 


Chapter 17 


Mathematical Vanity Plates 


[To be published, in abridged form, in The Mathematical Intelligencer 

33 ( 2011 ).] 


Introduction 

This story began in the spring of 1967 when I made a visit to Madison, 
Wisconsin, in order to give a lecture at the university. I was driving 
near the campus on a fine, sunny day. There was moderate traffic, and 
when a red light stopped me I happened to glance at the license plate 
of the car ahead. My jaw dropped — wow! It said “H65-536”. I can still 
picture that plate in my mind, as plain as day (see Figure 1), although 
more than forty years have passed. 



Figure 1 . A historic 
license plate, recreated 
in 2009 via the magic 
of Adobe Photoshop®. 


I started to jump out of my car, thinking that I might approach the 
driver to ask him if he knew what a fantastic license number he owned. 
But the light turned green; he drove away and I was unable to follow. 
I’ll never know if he was aware that the state had assigned one of the 
most important numbers in mathematics to his car. How I envied him! 

Indeed, 65536 is not just an ordinary power of 2, and not simply the 
order of the multiplicative group in the Galois field of the largest known 


121 


122 Selected Papers on Fun and Games 


Fermat prime. It is 



a number of huge importance in computer algorithms. Already in 1967 
I had become a big fan of this number, and my appreciation has contin- 
ued to grow as I continue to learn more. 

The Old Rules 

In those days each state of the USA required its drivers to purchase new 
license plates with new license numbers every few years, assigning the 
values in sequence. Thus your chance of getting any particular num- 
ber n was at most 1/n. People began to covet the small numbers — 
not because small numbers are mathematically interesting (which they 
are), but because small numbers are easy to remember. Small numbers 
also connote rank: The governor was number 1. The New York Times 
reported in 1959 [87] that 

[a state commission] is recommending the elimination of thou- 
sands of “distinctive number plates” — unofficially called “van- 
ity” plates. Low-numbered “vanity” plates have had a long and 
distinguished history in the automobile business. They have 
traditionally been obtained by politicians for their friends and 
campaign contributors. They have long been doggedly sought af- 
ter by celebrities, egomaniacs and men who have everything. 

Last year about 69,000 New Yorkers paid $5 extra for special 
low-numbered plates. 

About 5 million automobiles were registered in New York state at that 
time; New York plates contained one or two letters to encode a county, 
together with a serial number. The $5 fee for distinctive plates with 
fewer than six letters and/or digits had been inaugurated in 1954 [1]. 

Clever people didn’t actually have to settle for a random number on 
their licenses, however. It was perfectly legal in many states, including 
New York and California, to get your plates in a remote county, far 
from where you lived. During a vacation to a sparsely populated area, 
you could drop in to the local office and obtain decent numbers without 
much competition. Furthermore, your initials might well be available in 
some rural county. 

My father-in-law, who lived at 525 Summit Street in the medium- 
sized city of Fostoria, Ohio, was able to drive Ohio plates reading 525 S 
(his address) ever since the 1950s, because he was a friend of the local 
people who were in charge of auto registration. 


Mathematical Vanity Plates 123 

Beginning in 1967, Wisconsin motorists could obtain plates of the 
forms A9, A99, A999, A9999, or AA999 by paying a surcharge, where 
A denotes any letter and 9 denotes any digit. Thus a person could pay 
to have G256, say, but not H65536. 

I like to imagine that the man who acquired the plate in Figure 1 
had obtained it on a day when he knew that the 65,500s were being dis- 
tributed. By carefully trading places with people behind him in line, he 
could then have seized the opportunity to get the license number of his 
dreams. Wisconsonites are friendly folks who would have been quite will- 
ing to accommodate such a whim - unless of course two mathematicians 
had been in the same line. 

Every state in the USA has its own esoteric rules about license tags, 
except in one respect: All plates made since 1956 or so have the same 
size, 6" x 12", so that automobile manufacturers know how much space 
to allocate for plate display on their cars. 

When California adopted the standard size, it had to rethink the 
format of license numbers because the existing plates were somewhat 
larger. The old ‘digit-letter-digit-digit-digit-digit-digit’ style was capable 
of distinguishing 26,000,000 vehicles (see Fig. 2); but a maximum of 



FIGURE 2. A typical California 
license plate of the early 1950s, 
faked by Photoshop®. 


six characters was desirable on the new plates, and California had more 
than 5.5 million registered cars [2], So the authorities introduced a 
new tagging scheme in which all passenger cars were identified by three 
black letters followed by three black digits, on a yellow base, potentially 
allowing 230 3 = 12,167,000 combinations. (The letters I, 0, and Q were 
excluded.) These plates were distributed in batches of 1000 to district 
offices; thus you could easily identify where any given license had been 
obtained, by knowing the local letter codes. As before, the plates were 
designed to last for several years. Drivers were annually expected to 
purchase little stickers to paste in the upper right corner, as proof that 
they had renewed their registration. 

By 1963 it was time for new plates, and all Californians got new num- 
bers again. The new scheme featured three yellow letters followed by 
three yellow digits, on a black base; my wife and I received WHZ 065. 



124 Selected Papers on Fun and Games 



(Mnemonic: “Whiz by at 65 miles per hour” — the legal speed limit.) 
I didn’t realize until later that, with this plate, we already owned three of 
the six characters in Figure 1. Notice that if I had been just 66 places ear- 
lier in the queue, my car would have been repeatedly asking, “WHY 999”? 

Late in 1962, a determined 30-year-old man named Bill Sherinyan 
had driven from Los Angeles to the small town of Alturas in the rugged 
northeastern corner of California, where he stood in line for 42 hours, 
braving both cold and rain to win the ultimate prize: California license 
AAA 000, the first of the new series [3]. I remember seeing him inter- 
viewed on television when he substituted this trophy for his former plate 
(which incidentally was WWW 333). 

“There is a motorist in Marysville who has a plate reading ACH 000. 
Gesundheit.” [60] 

Three-Letter Words 

The 1963 licenses began to allow the letter Q as well as the vowels I 
and 0, in the first and second positions, thus forming many new three- 
letter combinations with familiar connotations. Back in those days L0L 
didn’t make anybody laugh; but the license ONE 234 was quickly spotted 
on a black Corvette [80]. Staunch Democrats refused to accept GOP, but 
HIS and HER plates became popular with two-car families [40]. 

More serious, however, were three-letter combinations that were 
patently offensive, like (censored), (censored), (censored), and (cen- 
sored). California’s license czars had foreseen this problem already in 
1955, when they asked Prof. Emeneau of the linguistics department at 
UC Berkeley to find all of the unsuitable words in the set 

{A, B, C,D, E, F, G, H, J, K, L, M, N, P, R, S, T,U, V, W, X, Y, Z} 3 . 

He and his helpers “came up with 152 no- nos” [60], including the word 
YES — because they feared that a woman might be uncomfortable with 
such a plate. 



Mathematical Vanity Plates 125 

I was told many years ago that Stanford Research Institute was 
asked to revise the UC list of banned words after I, 0, and Q became 
permissible, but I haven’t been able to confirm this rumor. And the 
revised list continued to grow; I do know that LSD and PIG became 
proscribed in the late 1960s [60], George Reasons, a reporter for the Los 
Angeles Times , was evidently allowed to peek at the list in 1962, because 
he wrote an amusing essay that incorporated 34 of the excluded triples: 

They’ve DUN it again. Some BUM at the Department of Motor 
Vehicles ordered all the FUN out of license-plate watching. It’s a 
GYP. . . . They HAD some SAD SAK at the University of California 
CUL out all of the GAG words. . . . DUM if you ask me. We lost 
some pretty good watching words, SOB, SOB. . . . GEE, nobody 
argues about taking out references to GOD and minority groups. 
They get RAW. And everybody knows SEX is BAD. . . . BRA I can 
see. BUT BVD? . . . BAH. [79] 

By 1979 the BAD list had grown to 215 items, which are now posted 
online [49], But state authorities began to relent in 1993, and 75 of 
those 215 now do occur on ordinary plates — including YES, as well as 
the words BUM, GYP, HAD, SAD, GAG, and BAH in the quotation above. On 
the other hand, four new combinations (including HIV) are now DOA [49]. 

California’s Department of Motor Vehicles has always disallowed 
CHP (California Highway Patrol) and CIA (Central Intelligence Agency) 
on license plates; but DMV is OK. Perhaps they don’t know that DMV 
stands for Deutsche Mathematiker-Vereinigung. 

Four-Letter Words 

American license plates rarely contained more than two letters during 
the first half of the 20th century. The reason may have been that license 
numbers were regarded as, well, numbers. Or perhaps officials realized 
that the possibilities for mischief grow exponentially as the number of 
letters increases. At any rate, motorists continued to want more and 
more varieties of personalized license tags, until finally the concept of 
vanity plates became much broader than before: Instead of simply hav- 
ing small numbers and/or our own initials, we’re now essentially free to 
express ourselves in any tasteful way. 

Seeds of this revolution were planted in 1937, when Connecticut mo- 
torists with a good driving record were allowed to get plates containing 
just their three initials. Four-letter combinations appeared in Connecti- 
cut during the 1940s [9]. New Hampshire issued vanity plates of up to 


126 Selected Papers on Fun and Games 

five letters in 1957; and Vermont followed soon after, allowing letters 
and numbers to be mixed. (See [48,65,90].) 

After a few years, the idea of decorating automobiles with personal 
names gradually began to evolve into the display of personal statements. 
For example, when vanity plates of up to five letters became available 
in the District of Columbia in 1964, people’s first choices were the one- 
letter plates from A to Z; numbers 1,2,3 were pre-reserved for the mayor, 
deputy mayor, and city council chair. (I don’t think 0 was permitted.) 
Five years later, Colman McCarthy [71] surveyed the 6000 choices that 
DC drivers had reserved during their first years of plate-naming freedom. 
He found that most motorists chose their initials or their first names, in 
order to make their cars look swanky. A second group, reacting against 
“faceless numbers sent by a faceless computer,” wanted to be identified 
in a more personal way using nicknames; the B-names in this category 
were BABS, BABY, BALDY, BEBE ( not owned by Mr. Rebozo), BIRDY, BOBO, 
B00FY, BUBI, BUNNY, BUTCH, and BUZZ. 

But the new folk art of devising witty licenses was also beginning 
to develop in DC: A man named Carl Levin got C-ll for himself and 
S-ll for his wife Sonia. A man named Ware had two cars, respectively 
AWARE and BWARE. A retired Navy captain’s Buick sported the license 
AWOL, received as a gift when he stepped down as head of the Citizen’s 
Association of Georgetown. Uplifting messages like FAITH, HOPE, LOVE, 
JOY, MERCY, PEACE (and PAX) were also in evidence. Although YES was 
forbidden in California, the District of Columbia had both YES and NO as 
well as 0UI; also OH NO, SORRY, and OOPS. Somebody in the nation’s capi- 
tal had MONEY, and I imagine somebody else had POWER but McCarthy 
didn’t speak to that. 

California Vanities 

A definitive history of vanity plates has yet to be written, and I’m cer- 
tainly not qualified to write it. But I can perhaps shed some light on 
the California side of the story, because I’ve lived in that state for nearly 
fifty years. 

All-letter licenses in California had an eccentric debut: One of the 
first of the 1963 plates to be printed was discovered to read YOUBUM. 
(It was smuggled into a DMV office by the clever convict or convicts at 
Folsom prison who had manufactured it for the state [4] . This plate, and 
a later one that said HELP, unfortunately had to be destroyed.) The tale 
took yet another twist in 1967, when dozens of souvenir plates reading 
THANKS were given out as Republican Party favors at the inauguration 
dinner for Governor Ronald Reagan [50] . Later that year, a resident of 


Mathematical Vanity Plates 127 

Pomona was spotted with a POMONA plate from Massachusetts; it was 
legal for him to use the license he had obtained for a car leased in that 
state [5]. (Massachusetts had introduced vanity plates containing two 
to six characters in 1966 [69].) 

Finally the lid came off in 1970. Page 1 of the San Francisco Chron- 
icle proclaimed, on 22 August 1970, that “Senator Milton Marks finally 
won his 10-year fight yesterday to allow Californians to order car li- 
cense plates carrying letters or numbers they desire.” Motorists were to 
pay $25 for this privilege, and $10 per year afterwards, all earmarked 
for a special fund to fight pollution; thus the plates became officially 
known as environmental plates. When Governor Reagan signed the bill 
authorizing this new policy, sitting next to a giant replica of a license em- 
blazoned CLEAN , he predicted that the plates “will serve as a symbol of 
the motorist’s personal concern for preserving and enhancing the beauty 
of California’s environment.” Application forms were available at DMV 
branches statewide, allowing people to list three choices, and giving four 
examples of the new possibilities: CLEAN, ZAP, WOW, and I KNOW [6]. Up 
to six letters and/or numbers were permissible, plus an optional space. 

Hundreds of motorists responded almost immediately. Among the 
first requests were PAID 4, OREGON, TURTLE, WHY WAR, GRANNY, and 
32 FORD [31,46,91]. Initial applications were collected for 30 days so 
that the most popular choices could be awarded by lot; but afterwards 
the rule was to be strictly first-come, first-served. The most wanted 
words, among about 10,000 applications received by September 22, were 
PEACE, SMILE, JAGUAR, GEORGE, TBIRD, BOB, LAWYER, MARGIE, MORGAN, 
LARRY, SNOOPY, LOVE, in decreasing order of popularity. A drawing was 
held in San Francisco on October 26 to select the winner among 38 ap- 
plicants who sought PEACE; another, in San Diego, determined which 
of 20 Californians would SMILE. The first California vanity plate actu- 
ally delivered, however, was presented in Sacramento by the governor on 
that day to Mr. and Mrs. Robert E. Klees, who had submitted the only 
request for AMIGO. Then Reagan drew from a hat to decide which of 
four candidates should have NO SMOG. (See [7, 35, 61, 84].) By December, 
the number one Christmas gift in southern California was a new license 
plate with a message like H0H0H0 or XMAS 70 [29]. 

Californians purchased more than 65 thousand personalized plates 
during the first 1.5 years, thereby raising more than $1.5 million for the 
environmental fund; about 1500 new requests were being processed each 
week. The fund had received $18 million by 1977, and a total of 423,213 
plates had been issued before April 1979, although 55,523 of them had 
not been renewed. California began to use narrower letters and numbers 


128 Selected Papers on Fun and Games 

in 1979 so that the licenses could contain up to seven characters; thus 
many more choices became possible, and about 600 new applications 
began to be filed every day. The millionth environmental plate was pro- 
duced in 1982, at which time about 750,000 were actually in circulation. 
(See [8,21,62].) 

A Complete List 

One of my cherished possessions is the official list [20] of all California 
environmental plates that were current on 21 July 1981, obtained from 
a friendly administrator in 1982 when I explained that I was a computer 
science professor interested in database research. Altogether 665,571 
entries appear in this list, and I estimate via random sampling that 
about 40% of them have length 7. 

What a wealth of ingenuity exudes from almost every page! For ex- 
ample, I wondered if anybody had wanted to put BONFIRE on their vanity 
plate; sure enough, there it was — together with B0NFYR and B0NFYRE, 
as well as FAL0, FAL01, and FAL02. 

To get an inkling of this 836-page list, let’s consider page 316, which 
contains 798 entries from H0WZEIT to HRNDEZ. Among them are 


H0WZIT 

HP 

HPN0SIS 

HRCULES 

HRD2GIT 

HRIZ0N 

H0W2WIN 

HPBMW 

HP0WER 

HRDC0RE 

HRD2PAS 

HRLEQIN 

H0XIE 

HPB00KS 

HPTYH0P 

HRDR0CK 

HRD2PLZ 

HRMI0NE 

HOY 

HPB0SS 

HPYTRLS 

HRDRSR 

HRD24GT 

HRMMPH 

HOYLES 

HPBRDAY 

HRBL0CK 

HRDT0P 

HRG0D 

HRMNIZE 

H0ZWIFE 

HPENNY 

HRB0NUS 

HRDWARE 

HRH 

HRNBLWR 


and another word that I’ll mention later. (Spaces have been suppressed 
because they don’t count, in the DMV’s test for equality of names.) 

One thing that’s immediately clear is that people with the same idea 
have been forced to spell it in different ways. We find plates like PLEYB0Y, 
JIG0L0, F0RSAIL, ST0LIN, JILL0PY, LAEM0N, N0WHEY, and P0ETIQ; of 
course this is just poetic license. 

All 24 letters of the Greek alphabet are present in [20] - - except for 
ZETA and XI, which are represented by ZETA7 and XICHI. And they 
often occur with “subscripts”: ALPHA0, ALPHA 1, ..., ALPHA8, as well 
as ALPHA01 and ALPHA99 (which I guess were chosen by statisticians or 
social scientists). Latin scholars have contributed ERG0SUM, ERG0IAM, 
and ERG0IG0. We find both PUBLISH and PERISH, as well as HANSEL and 
GRETEL, PEARL and OYSTER, GOLD and SILVER, D0NNER and BLITZEN, etc. 


Mathematical Vanity Plates 129 

Yet there also are surprising gaps: The English numerals ONE, 
THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, ELEVEN are present 
and accounted for, but TWO and TWELVE are lacking. Nobody in 1981 had 
even thought of VEHICLE. There was neither YIN nor YANG. Music lovers 
had named their plates after HAYDN, MOZART, B8H0VEN, BRAHMS, and 
MAHLER; also BACH, BACHJS, JSBACH, JSBACH1, and PDQBACH. But not 
(yet) BERLIOZ, DVORAK, or MILHAUD. Somebody had OPUS 132. ADAGIO, 
ALLEGRO, ANDANTE, LARGO, and PRESTO? Yes. LENTO and VIVACE? No. 

Other States 

I’ve already mentioned early appearances of vanity plates in Connecti- 
cut, New Hampshire, Vermont, Massachusetts, and the District of 
Columbia. Many other states, like New Jersey, New York, and Penn- 
sylvania, allowed motorists to pay extra for plates that were especially 
desirable, provided that they would stick to letters and numbers that 
conform to the ordinary license number syntax. 

I ran across a few other facts while researching the California story, 
such as the following front-page item in the Wall Street Journal for 
7 May 1969: 

To glean extra revenue from auto licenses, New Mexico began of- 
fering “prestige plates” — auto tags with any letters a car owner 
asked for — for a $25 premium. The executive secretary of the 
New Mexico Cattle Growers Association ordered BEEF and a 
Volkswagen owner asked for BUG. But last year, the state sold 
only 155 vanity plates. Now the legislature has marked down the 
price to $15 (as of June 20), in hopes that car owners will go for 
cut-rate status. 

A brief note on page 15 of the Baltimore Afro-American, 8 July 1967, 
reported that “The North Carolina Department of Motor Vehicles is 
accepting applications for personalized 1968 license plates.” And a filler 
item from Texas on page 21 of The New York Times, 6 February 1969, 
stated that 

Personalized license plates are the thing in Fort Worth despite 
the $10 extra cost. One motorist got big red-lettered plates 
reading SMILE. . . . The most exuberant ordered YIPEEE. More 
than 1,000 persons have ordered special plates. 

Thus the phenomenon was certainly becoming contagious. A survey by 
Robert E. Dallos in 1977 [27] reported that 

A dozen years ago, fewer than 15 states offered special plates. 
Now, only Mississippi doesn’t have them. . . . South Dakota’s 


130 Selected Papers on Fun and Games 

plate law went into effect July 1. Although it had passed the 
Legislature a number of times, it had always been vetoed by 
the governor. This time it was allowed to take effect because, 
according to a spokesman, the state could use the $50 initial fee 
and $35 annual charge. 

The revolution still wasn’t complete in the 1970s, however, because 
several states were still severely limiting the amount of allowable per- 
sonalization as Wisconsin had done in 1967. Wisconsin began to allow 
genuine “own choice” plates in 1979, followed by Illinois in 1980, Missis- 
sippi in 1981, and West Virginia in 1982 [85]. Even today, Massachusetts 
requires all numbers to be preceded by letters; you can say MITPHD or 
MIT69 but not MY69MG. Furthermore there must be at least two letters. 
Illinois is similar, but there must be a space separating letters from num- 
bers. (The pure numbers 1 to 999 are said to be legal in Illinois, but 
they were all snapped up long ago.) 

Stefan Lonce, working with the American Association of Motor Vehi- 
cle Administrators, collected statistics from all 50 states and the District 
of Columbia, determining the total number of registered motor vehicles 
in 2005 as well as the total number that were “vanitized” as of 2006 
or 2007. The results [66] showed that the current fraction of vanity 
plates in the USA was 9292843/242991747 « 3.8% at that time, with 
greatest penetration in Virginia (1065217/6578773 ~ 16.2%) and least 
in Texas (97315/17347615 « 0.6%). California ranked 22nd, with a ratio 
of 1136772/32592000 w 3.5%. 

These statistics make it clear that vanity plates have now become 
thoroughly integrated into American pop culture. Several books have 
been written on the subject [25, 30, 44]; see also the nice survey of vintage 
1986 plates by Faith W. Eckler [34]. 

A complete list of current South Dakota vanity plates, containing 
15,483 entries from 001 to ZZZZ00M, was posted on the Internet on 25 
October 2009 [67], and it’s interesting to compare it to the California list 
of 1981. The interval from page 316 of [20], discussed above, intersects 
the South Dakota data in only three cases: HPYDAYS, HPYTRLS, HRDR0CK. 
There are 22 other South Dakota plates in the corresponding interval, 
including HPBD2ME, HPYGIRL, HRDLUCK, HRDLY, HRH0TRD, and HRMSWAY. 

Choices with inappropriate connotations, as discussed above for 3- 
letter words, must of course be weeded out by committees in each state. 
Sometimes the prisoners who manufacture the plates are able to help 
by catching obscure obscenities at the last minute [8]. An interesting 
game remains, however, to get past the censors with “dirty words” that 
still are sufficiently highbrow to be acceptable in polite company. The 


Mathematical Vanity Plates 131 

best I’ve seen in this category so far are SWIVE (a Chaucerian verb) and 
HRAKA (a Lapine noun from Richard Adams’s Watership Down). 

The Challenge 

So how do mathematicians fit into this trend? Dentists can advertise 
their specialty with “dental plates” such as DENTIST, 2TH DR, DRILLER, 
SMILE, MOLARS, CUSPID, GUMSAVR, NO DK, FLOSSEM, CROWNS. Physicists 
now sport licenses like PHYSICS, NUCLEON, DELTA S, GLAST, XRAY BMR, 
CY N TIST, E PLUS, and E MINUS [26]. And of course E COLI [20] belongs 
to a biologist. 

If you, like me, don’t already own a vanity plate, what would be 
your first choice? What’s the briefest and best way to represent yourself 
to the world? If there’s something that’s uniquely you, there’s a greater 
chance that it won’t already be reserved. 

Ideally your choice should bring a smile to people who see it. They’ll 
think, “Aha! A person who loves mathematics!” Alternatively, you 
might choose something that will please and amaze specialists, although 
the masses won’t get the point; that can still lead to teachable moments. 

Many of the things we deal with as mathematicians involve words 
that are much too long: MATHEMATICS, ARITHMETIC, DETERMINANT, 
CONJUGATE, DIFFERENTIAL, INTEGRATION, COMPUTATION, PERMUTATION, 
LOGARITHM, ALGORITHM, COUNTEREXAMPLE, etc., etc. There are some 
shorter terms like MATHS, ALGEBRA, SINE, COSINE, TANGENT, MATRIX, 
GROUP; but they’re in [20], already claimed ages ago. What’s left? 

I remember discussing this question with my son, long ago when he 
was in elementary school and vanity plates were fairly new. I told him 
that, ha ha, our car should say VANITY. (I naively believed that this was 
an original thought.) 

But he had a much better idea: How about letting the plate be 
entirely blank? At that very moment I realized that he was a budding 
mathematician, wise beyond his years. For indeed, what could be more 
vain, yet more rich in mathematical properties, than the empty set? 
This idea trumps even the governor’s number 1. 

Unfortunately, though, the empty string is too short a word for state 
bureaucrats to understand. And even if they did issue a blank plate when 
you left the form blank, what do you think highway patrolmen would 
do when you drove by? Not everybody understands nullity, alas. 

On the other hand — surprise — I happened to spot 7 SPACES, on 
8 August 2004. Aha, I learned, the empty plate does exist! (Moreover, 
7 BLANKS is still available in California, as of 5 November 2009.) 


132 Selected Papers on Fun and Games 


The Character Set 


Before we investigate the possibilities further, we need to know the 
ground rules, which differ from state to state. 

The most important limitation is the total number of characters. 
Wyoming residents are expected to be most creative: They must express 
themselves in four symbols or less, in order to leave room for a county 
code and the famous bronco-buster logo. (Unfortunately, this state and 
some others have recently switched to “digital plate technology,” pro- 
duced by laser printing instead of embossing, with an atrocious font. It 
looks cheap, perhaps because it is. If I lived there I’m afraid I would 
choose the word UGLY until they reverted to the beautiful style of 2002.) 

The maximum message length in Alaska, Connecticut, Hawaii, Ken- 
tucky, Maine, Massachusetts, Missouri, Oregon, Rhode Island, and 
Texas is 6. All other states have a limit of 7, except for New York, 
North Carolina, and West Virginia, where you can (gasp) go up to 8. 
Only in the latter three states can you claim GEOMETRY or TOPOLOGY. 

What can those 4 or 6 or 7 or 8 characters be? All 26 uppercase 
letters from A to Z are legal, and New Mexico allows also N. The digits 2 
through 9 are obviously all OK too. But 1 is equivalent to I in Louisiana 
and Minnesota; and 0 presents a really sticky problem. 

Consider the following nineteen entries from [20]: 


00 0000 00000 00000 000000 
00 0000 00000 00000 000000 


0000000 0000000 
0000000 0000000 
0000000 0000000 


There are 240 or 241 combinations* of 0 and 0 that don’t conflict with 
plates in the ordinary sequential series; by July of 1981, Californians 
had reserved those 19. These plates must have caused nightmares for 
police officers because they’re so hard to distinguish. Therefore 0 and 
0 have now become identical in California; also in Colorado, Louisiana, 
Minnesota, Nevada, North Carolina, Vermont, and Wisconsin. I don’t 
know when this change was made, or if cars with visually ambiguous 
licenses are still on the road in California. 

South Dakota still considers 0 and 0 to be distinct; I know this be- 
cause [67] lists both 0000000 and 0000000 but no other combinations of 
length 7. Massachusetts does too, because AUTO is taken but AUTO is not. 


* I don’t know if 0000000 would have been legal. California plate 999ZZZ 
in the ordinary series was followed by 1AAA000 in April of 1981; plates 
numbered 2AAA000, 3AAA000, 4AAA000, 5AAA000, and 6AAA000 came out in 
1984, 1992, 1999, 2003, and 2007, respectively. When the present series runs 
out, 9ZZZ999 probably won’t be followed by 0AAA000. But who knows? 


Mathematical Vanity Plates 133 

The most interesting variation between states, vanity-wise, is the 
set of allowable delimiters or punctuation marks that can appear. My 
eyes popped in 1985 when I first saw New Hampshire plates containing + 
signs as well as - signs, opening up a whole new world of mathematical 
vanities. Complex analysts in the Granite State can adorn their cars 
with X+IY. (California now has + signs too; see below.) New Hampshire 
had used heavier, red-cross-like symbols on their license plates for ambu- 
lances since 1939 or earlier. In 1974 they reserved AMB for ambulances, 
and eventually they made vanity pluses available for use by anybody [47] . 

Furthermore, New Hampshire drivers are able to use ampersands. 
Hence they can construct the wonderful formula -X&X, which yields the 
least significant 1-bit, if any, in the binary representation of X (see [58, 
Eq. 7. 1 .3— (37)] ) . I checked both X+IY and -X&X on New Hampshire’s 
website in November 2009, and both of them were available. But X&-X 
was illegal, because consecutive punctuation marks are forbidden. 

Most states allow only letters and digits. But a minus sign (hyphen) 
is permissible in Alabama, Colorado, Delaware, Florida, Kentucky, 
Louisiana, Minnesota, Missouri, New Mexico, North Carolina, Okla- 
homa, Oregon, Pennsylvania, Virginia, and Washington, as well as New 
Hampshire. An ampersand is legal in Delaware, New Hampshire, North 
Carolina, North Dakota, South Carolina, and Virginia. You can use a 
dot in Colorado, Connecticut, Louisiana, and North Carolina. Apostro- 
phes are OK in Missouri, New Mexico, and (again) North Carolina. 

Noith Carolina, in fact, is Vanity Plate Heaven. We’ve seen that 
tarheels are able to enjoy up to 8 characters that include pluses (+), mi- 
nuses (-), dots (.), and apostrophes (’); and in fact they can also have 
number signs (#), question marks (?), dollar signs ($), asterisks (*), 
slashes (/), equals signs (=), at signs («), colons (:), double quotes (")’ 
commas ( , ), and exclamation points ( ! )! Unfortunately for mathemati- 
cians, the list stops there; parentheses, and the relational signs < and > 
aren’t permitted. Unfortunately for T^X users, backslashes and curly 
braces are lacking too. 

But hey, $720=6 ! $ in this state. Calculus and physics teachers can 
have $dx/dt$, etc. (All special characters are ignored when comparing 
two plates; thus 7206 and dxdt would be indistinguishable from those 
examples, and so would #7+2/0-6 and dx/dt?, both of which happen to 
be presently available subject to approval by the authorities.) 

I wonder if a fallacious proposition like $120=6!$ would also be 
acceptable to the North Carolina censors. Probably it would, thereby 
setting back education in the Southeast. Even worse, I fear that some- 
body will ask for BADQMATH and be proud to display it. But let’s not be 


134 Selected Papers on Fun and Games 

pessimistic; North Carolina deserves applause for leaping way ahead of 
everybody else. 

Besides ordinary punctuation, a few special characters are also avail- 
able. New Mexico has an enchanting Zia Sun symbol, which their website 
illustrates with the example VANOITY. New York offers a blob in the 
shape of its empire, which I won’t illustrate here. 

Since 1994, California has allowed a single delimiter to appear on 
vanity plates, taking the place of a letter or digit. There are four choices: 
Drivers can use either a plus sign or one of the unique symbols {#,*,»}. 
The senior co-editor-in-chief of this journal could be CiULER D if he moved 
to California; Steve Smale could be tLE BODY. Both of these are cur- 
rently up for grabs, as are X+IY. IVMATHS, and L*SPACE. 

The rules for spaces (I mean blank spaces, not L*-spaces) are too 
complicated to explain here. Suffice it to say that most states allow you 
to insert them in order to improve readability. 

Examples on the Road 

Let’s look now at how some mathematicians and/or their friends have 
risen to the occasion by meeting these constraints. 

Cathy Seeley, who was president of the National Council of Teachers 
of Mathematics (NCTM) from 2004 to 2006, likes her license plate so 
much that she included it in an illustrated lecture that I found on the 
Internet: 


_ a c%?msth 


Hi 


TEXAS * 

DO-MATH 

and can d<? anything! ’** 


.J 


Figure 4. An exhortation. 


Her plate sits in a holder that was in fact produced by the NCTM, saying 
“Do math and you can do anything!” (I’d amend that to “Do math and 
learn to write, and you can do anything” — but my version wouldn’t fit.) 

She told me about two other nice examples: Ed Rathmell, a math 
professor at the University of Northern Iowa who does a lot of work 
with education, is MATH ED. And Gail Englert, a middle-school math 
teacher in Norfolk, Virginia, has IEDUK8M, with a nice play on ‘K-8’ in 
education. 



Mathematical Vanity Plates 135 

David Eisenbud, who was president of the American Mathematical 
Society (AMS) during 2003 and 2004, received an appropriate plate from 
his wife shortly after he became director of the Mathematical Sciences 
Research Institute in 1997: 



Incidentally, when I spotted the California plate I AM PAMS on 2 Jan- 
uary 2001, 1 realized that it did not refer to Proceedings of the American 
Mathematical Society because Clifford J. Earle, Jr. was at Cornell. 

Vanity plates that name the basic words of our discipline are more 
difficult to come by, because more people try to reserve them. Victor 
Miller has been doubly successful in this regard, because he not only 
owned New York ALGEBRA in 1978, he purchased New Jersey ALGEBRA 
in 1993! He still drives it: 

I * New Jersey • ITT 

ALGEBRA 

• Garden State * Figure 6. An acquisition. 


Dave Bayer is another lucky mathematician who obtained the plate 
of his dreams, perfectly suited to his work on geometric invariants [14]: 



Figure 7. A celebration. 



136 Selected Papers on Fun and Games 


He is evidently not alone, because the California list from 1981 [20] 
already contained SYZYGY, SYZYGY1, SYZYGY2, SYZYGY3, SYZYGYS, and 
SYZYGYX, as well as SYZ WIZ. 

The key words NUMBER, THEORY, and THEOREM were also unavailable 
to Californians who sought new vanity plates in 1981. But eventually two 
of them came back into play: Fan Chung and her husband Ron Graham 
(the AMS president in 1993 and 1994) now have personal plates, acquired 
in 1999, that are amazingly appropriate when parked side by side: 


FIGURE 8. A perfect matching. 

The existence of Ron’s plate implies that THEOREM is once again 
unavailable; so I used the DMV website to try for LEMMA. It, too, is 
currently taken, and so is DILEMMA. So are MATRIX and VECTOR; but 
not TENSOR. (According to [67], NUMBER, THEORY. THEOREM, LEMMA, 
DILEMMA, MATRIX, VECTOR, and TENSOR are all presently available in 
South Dakota, as are DO MATH, MATH SCI, ALGEBRA, and SYZYGY. This 
observation doesn’t prove that South Dakotans are anti-mathematics; 
indeed, [67] does list MATH ROX, NUMBERS, and NUMB3RS.) 

Fan and Ron also share an RV with a tag that commemorates their 
joint work on quasi- random graphs and other structures [22]: 




*WM 


ORANDDM 


FIGURE 9. A collaboration. 


(This license plate incidentally illustrates the unfortunate fact that Cali- 
fornia has never figured out how to make a decent-looking letter Q . From 
a typographic standpoint, Wisconsin and other states would actually be 
much better places to advertise QRANDOM research.) 






Mathematical Vanity Plates 137 

Ron tells me [45] that he often sees 2+2 R 4 in the parking lot of 
the math building at UCSD; another one is S CUBED. At a higher level 
he also encounters RC FLOW, representing Ricci flow — the key idea with 
which Grisha Perelman resolved Poincare’s conjecture [77], 

Andy Magid has said [68] that he’s the only licensed Galois theorist 
m Oklahoma, because he drives GALOIS. “Most people who read or have 
to record my car tag, such as tow truck operators or highway patrol 
officers, do so without comment or even accurate pronunciation. But on 
occasion it does provoke welcome conversation.” 

What about the names of other famous mathematicians? I checked 
a few, to see what California drivers have selected, and got a shock: 


in use? 
1981 
2009 


FERMAT EULER LAPLACE FOURIER GAUSS GALOIS HILBERT 

no yes yes no no no no 

yes no yes yes yes no yes 


Alas my personal hero, Leonhard Euler, has waned in popularity out 
west. (But David Robbins did have New Jersey EULER for many years.) 

The license plate BIG OH has been spotted in New York [86], and 
it’s also present in California. I love that notation [56], At present New 
Yorkers, like me, are less enthusiastic about LITTLE OH. 

My colleague Ingram Olkin in Stanford’s Department of Statistics 
received STAT PRO as a gift from his children about ten years ago. His 
daughter Julia now has the California plate S0LV4X; she really wanted 
S0LVE4X, but it was already taken in 1981 [20], 

California’s 1981 list had OPTIMUM, MINIMUM, and MAXIMUM: also 
OPTIMAL and MINIMAL but not yet MAXIMAL. It included both MINMAX 
and MINIMAX, as well as MAXIMIN and — my favorite — MAXIMOM. There 
was a Z AXIS on the road, but no X AXIS or Y AXIS. Somebody had 
DY DX; another had DU DS but without the space. 

Fifty- two of the California environmental plates in 1981 began with 
MATH. Some of them, like MATHER, MATHEW, and MATHIS, were surnames 
that aren t relevant to our discussion; MATHIEU may, however, have be- 
longed to a group theorist. Noteworthy are MATHBIZ, MATHMAN, MATHPRO, 
MATHS, MATHWIZ, and MATH4U . I fear that MATHANX was supposed to sug- 
gest anxiety rather than thank-you-dear-ma; and MATHOS was perhaps a 
feminine form of PATHOS. 

A light-hearted competition for the best vanity plate with a math- 
ematical theme was organized by the NCTM at the beginning of 2005, 
and prizes were awarded at their meeting in April of that year. First 
place went to a “pair o’ docs” named Carol and Roy Bohlin, who teach 



138 Selected Papers on Fun and Games 

at Fresno State University and always carry a trunkful of material for 
the math classes and workshops that they teach: 


Other winners included Hollylynne and Todd Lee, a young couple in 
North Carolina who had decided to marry when she (TCHUMATH) and he 
(MATHMTCS) saw each other’s license plates. 

Small Integers 

Of course license plates have traditionally featured numbers rather than 
letters, and nothing can be more mathematical than numbers. Therefore 
mathematical vanity plates often involve carefully selected numbers. 

Let’s start at the beginning with 0. We’ve already noted that Cali- 
fornia’s database from 1981 [20] had many combinations of 0 and 0. It 
also included D0UBLE0, D0UBLE0, DBL00; in fact, somebody even claimed 
0X0 EQ l! There was a vote for 00NUKES. My favorite from [20] in this 
category, however, is OOMPH —a plate that is not only pronounceable, it 
is semantically equivalent to STOPPED, if you think about it. 

Moving up, the use of 1 as a cardinal number and/or multiplica- 
tive identity was quite common, as in 1 BAD APL, 1 EGO FIX, 1 F0W VEY, 
1 HONKER, 1 LITER, 1 MOMENT. The ordinal 1 appeared too, in 1ST AID, 
1ST ALTO, 1ST HALF, 1ST LAP, 1ST N 10, 1ST VIOL. The plate 1F100 may 
have denoted a hypergeometric function; but it was most likely on a Ford 
F100 pickup truck. I don’t know the significance of 1DELTA1, 10MEGA1, 
1SIGMA1 (all found in [20]). 



Mathematical Vanity Plates 139 

geo? TEXAS eb 

i OR o | 

Figure 10. Shades of Leibniz and Boole. 

Laurence C. Brevard [18] tells the following story (see Fig. 10): 

I got 1 OR 0 in Texas in 1982 but the picture shows the 1984 
plate. Back then you got new plates every year instead of the 
stickers they use now. . . . After I moved to Oregon in 2001 I got 
the same plate “number” there. People consistently thought the 
OR stood for Oregon. Sigh. . . . Someone else has this plate in 
California! I also have had the domain lor0.com since 1998. 

May I suggest ORBITS? (Sorry.) ■■■■■■■■ 

Bill Ragsdale sent me a picture of the license 
which he spotted during a trip to China in 1984. He theorizes that 
China is moving to binary license plates due to the difficulty of their 
character set.” 

The website of Utah’s Division of Motor Vehicles [89] provides help- 
ful examples of personalized plates, including 2XX3XY, which certainly 
looks mathematical. Upon further inspection, however, this one actually 
turns out to be genomical: The driver has two girls and three boys. 

Indeed, I’ve rarely seen license plates that celebrate the beautiful 
mathematical properties of small integers. Why haven’t people chosen 
messages such as 0 IS NONE, 0 IS L0G1, 1 IS UNIT, 2 IS EVEN, 3D WORLD, 
4 COLORS, 5 IS F5, PERFECT 6, 7 FRIEZES, 8 IS CUBE, PAPPUS 9? A large 
territory remains to be explored. (In [20] I do find 1 IS ALL and 10ISBUF; 
but the latter surely was chosen by a tennis buff.) 

The 1981 collection [20] has many examples based on small numbers 
that occur in less mathematical ways: 7 COME 11, 8 IS ENOF, 9 LIVES, 
TEN FOUR, 12 STEPS, 12 TONE, 15 GRAND, SWEET 16, 24 CT, LOVE 30, 
49ER, 55 HAHA, 58 PROOF, etc. 

Francois Le Lionnais wrote a classic book [63] that is filled with 
good reasons to like particular numbers, and David Wells has written 
a similar but more elementary sequel [92], (See also De Koninck [28].) 
There s a well-known proof by induction that a 11 nonnegative integers are 
interesting; for if this statement were false, the smallest noninteresting 
number would certainly be quite interesting. QED. 




140 Selected Papers on Fun and Games 

Following this reasoning we can conclude that the number 62 is 
interesting, because it’s the smallest integer that appears neither in [63] 
nor in [92], The more recent book [28] lists only prosaic facts about 62. 

But John Conway has discovered that 62 also has a far more in- 
teresting property, namely that it’s the least n such that no number is 
exactly n times the sum of its digits. (See [83, sequence A003635].) We 
could make a vanity plate from that fact: WHATS 62. 

On the other hand, Gordon Garb [38] told me a cautionary tale. 
After having been excited and inspired by a reference to a paper by Li 
and Yorke entitled “Period three implies chaos” [64] , he once decided to 
acquire the California vanity plate PERIOD 3. Unfortunately, his choice 
didn’t turn out to be as cool as he had hoped: 

In the years that I had it on my vehicle, nobody ever got the 
Chaos reference. I explained it many times when friends asked, 
but what fun is an inside joke if you always have to explain it? 

My future wife told me years later that she just assumed I was 
a hockey fan. ... I replaced it with a vanity plate that simply 
has my typical login name. 

Roman Numerals 

Since the decimal system is only one of many ways to represent numbers, 
vanitizers have often opted to express themselves with the venerable no- 
tation of ancient Rome — the city where size XL was smaller than size L. 
For example, the plate IV appeared early on in New Hampshire [48]. 

An online search using the California DMV website reveals that the 
license LXIX is presently unavailable. Somebody may have snuck it past 
the censors, because my state allows this number to appear only on 
vehicles that were manufactured in 1969. 

When I originally received the early California list [20], I looked first 
for the entry DCLXVI , because I had a notion that it might be fun to drive 
around displaying the infamous “number of the beast” (see Revelation 
13: 18 and [39]). Alas, someone had beaten me to it. Roman numerals 
are in fact not uncommon in [20]; there are, for instance, 36 entries rang- 
ing from 1901 (MCMI) to 1980 (MCMLXXX), almost surely intended to stand 
for dates that have personal significance. Somebody also chose SPQR LXV. 

I’m writing this essay in 2009, the year that matches the name 
of my computer MMIX [57]. Perhaps my license should read MMIXMAN. 
(Or T0MMIX, which is playfully ambiguous.) 

Notice that Roman numerals can also be used in reverse, as in the 
sequence F4E, S9, SE5EN. 


Mathematical Vanity Plates 141 


Bond; James Bond 

What is the most-wanted three-digit number on a vanity plate? The win- 
ner, hands down, is 007. Uncountably many motorists have apparently 
dreamed of masquerading as Ian Fleming’s immortal character James 
Bond [37]. In the 1981 list [20], for example, one can find 


AGNT007 

DBL07 

JAMES07 

JMSB007 

007 

00VII 

B0ND007 

D0UBL07 

JBQND 

J007 

007B0ND 

007 

B0ND007 

DUBLE07 

JB007 

0H0HSVN 

007LIVZ 

007LIVS 

DBL0H7 

D007 

JMSB0ND 

0H0H7 

00SEVEN 

00SVN 


and probably more that I’ve missed. (The choice 007 was not allowed. 
Nobody had yet taken 007.) 

Some lucky Californian will get the license 7AKA007 as part of the 
regular (non- vanity) sequence, sometime during the year 2013, if present 
trends continue. Who will it be? 

In 1966, Sol Golomb created Bond’s illustrious binary cousin, Secret 
Agent 00111, when he introduced the concept of run-length encoding for 
sequences of bits [42] . Several of the exciting and bizarre exploits of this 
intrepid information trafficker were revealed later, in an introductory 
textbook [43], Agent 00111 either remained undercover in 1981 or failed 
to own a California vehicle at that time; but he or she is now driving 
somewhere in the state, and also in Florida. 

While we’re on this subject, I should mention that another counter- 
spy, Maxwell Smart [19], also has a huge following in the license plate 
subculture. Would you believe that the choices 

AGNT86 AGNT99 AGENT99 MAXWELL MSMART MSMRT MXSMRT 

AGNT8T6 AGENT86 CONTROL MAX86 MSMARTY MXSMART 86SMART 

all appear in [20]? 

Real Numbers 

Mathematics doesn’t limit itself to whole numbers, of course; many oth- 
ers are out there, including SURREAL ones [20,54]. 

What do you think is the first noninteger number that most people 
think of? You’re right: It’s n. 

To verify this hypothesis, I looked up the license plates that are cur- 
rently available in Florida, Michigan, Nevada, and North Carolina, which 
are among the few states that allow motorists to choose plates that con- 
tain seven digits and no letters. In each case the combinations 3141592 
and 3141593 have already been taken, but 3141591 and 3141594 have 
not. (Recall that tt 3.1415926535897932384626433832795028841972.) 



142 Selected Papers on Fun and Games 

This cannot be just a coincidence. In North Carolina, which allows up 
to eight digits, I checked for 31415926 and 31415927 as well, but those 
plates are still available. The 7r-fanciers of that state have most likely 
taken advantage of their typographic freedom by selecting plates with 
the decimal point included: 3. 141592 and 3. 141593. 

Arizona motorists have currently claimed 314, 3141, 31415, 314159, 
and 3141592, but not 3141593. Have they perhaps been basing their 
choices on the successive version numbers of TjrjK [55]? 

Although California doesn’t permit plates that are entirely numeric, 
the 1981 list [20] does include QT314, QT31415, and QT31416, as well as 
PI R SQ and PI R2. 

The people have spoken: n wins! 


FIGURE 11. Four mathematicians with a nonrandom license plate. 




Mathematical Vanity Plates 143 


Figure 11 is a historic photo from 1987 that shows four people who 
have made significant contributions to the high-precision evaluation 
of 7r: Gene Salamin, Yasumasa Kanada, David Bailey, and Bill Gosper. 
They’re gathered around Bailey’s appropriately numbered car. At that 
time Kanada held the world record, having recently computed 7 r to 
134,214,700 decimal places. He had helped with the first calculation 
that exceeded 2 million places, in 1981, but that record didn’t last 
long; Gosper had topped 17 million places in 1985, using some ideas 
of Salamin, and Bailey had surpassed 29 million in 1986, before Kanada 
got back in the lead [12]. More than two further decades of continued 
progress in mathematics, hardware, and software have led to the aston- 
ishing present record of 5,000,000,000,000 decimal places (yes, 5 trillion), 
announced on 2 August 2010. This major feat was achieved by Alexan- 
der Yee and Shigeru Kondo on a personal desktop computer, after about 
90 days of calculation [95] . 

David Bailey s current license shows 7r in a less familiar guise: 



Hexadecimal notation, which makes 7 r equal to 

3 . 243F6A8885A308D313198A2E03707344A4093822299F31D 

nicely meets California’s stipulation that all license plates must con- 
tain letters. And it’s also especially appropriate for Bailey, who helped 
to discover the remarkable formula 

OO 

7 r = - - —) 

16 fe V8& + 1 8A: + 4 8k + 5 8A: + 6/’ 

by which the nth hexadecimal digit of n can be computed efficiently 
without evaluating the previous n — 1 [12, 13]. 

Martin Davis currently drives around Berkeley with the vanity plate 
E I PYE. (He is also martin@eipye.com.) That’s a very nice formula; 
but I think my own preference would be SQRT 2PI, which happens to be 
currently available if I decide to go for it. 



144 Selected Papers on Fun and Games 

While writing this essay I tried to find other familiar constants (\/2, 
e, (f>, 7 ) by querying the appropriate websites in Arizona, Florida, Michi- 
gan, Nevada, and North Carolina. But I encountered only a few hits: 
Arizona drivers have reserved 271828, 1618PHI, and 1618033; North 
Carolina drivers have reserved 1.414214, 2.718282, and 1.618034; oth- 
erwise nothing. From this limited sample it appears that fans of Euler’s 
constant have not yet arisen to promote their cause, and that rounding 
is preferred in the East but not in the West. A rich vein of important 
numbers remains to be claimed, vanitywise. 

Sometimes, as in Figure 1, people obtain mathematically signifi- 
cant license plates purely by accident, without making a personal se- 
lection. A striking example of this phenomenon is the case of Michel 
Goemans, who received the following innocuous-looking plate from the 
Massachusetts Registry of Motor Vehicles when he and his wife pur- 
chased a Subaru at the beginning of September 1993: 



FIGURE 13. An anticipation. 


Two weeks later, Michel got together with his former student David 
Williamson, and they suddenly realized how to solve a problem that 
they had been working on for some years: to get good approximations 
for maximum cut and satisfiability problems by exploiting semidefinite 
programming. Lo and behold, their new method which led to a 
famous, award-winning paper [41] — yielded the approximation factor 
.878! There it was, right on the license, with C, S, and W standing re- 
spectively for cut, satisfiability, and Williamson. 

Large Numbers 

Let’s return now to the scenario we began with, a license plate that 
bore the desirable number 65536. Mathematicians have traditionally 
befriended numbers that are much smaller than this, because smaller 
numbers tend to have more interesting properties. (Or perhaps because 
smaller numbers have properties that are easier to discover without com- 
puter assistance.) Le Lionnais considered this situation in his postlude 



Mathematical Vanity Plates 145 

to [63], saying “Tous les nombres sont remarquables, mais peu ont ete 
remarques.” His book discusses 219 integers between 2° and 2 20 , hav- 
ing a total of 574 “properties,” with the following distribution of fc-bit 
numbers for 1 < k < 20: 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 


Figure 14. Remarkable numbers and remarkable properties in [63], 

Here the black bars stand for numbers and the gray bars stand for prop- 
erties, for example, when k = 1 the only 1-bit number is 1 and he 
mentions 14 of its properties. 

The sole number listed for k = 20 is 604800, the number of elements 
in the Hall-Janko group (the fifth sporadic group); this number also has 
the property that some of its divisors yield an interesting “congruence 
cover.” A congruence cover is a set of integer pairs (a u d x ), . . . , (a a ,d s ) 
with di < • • • < d s such that every integer is congruent to a k (modulo d k ) 
for some k. For example, the simplest congruence cover [36] is 

{(0,2), (0,3), (1,4), (1,6), (11,12)}. 

Robert C'hurchhouse [23] found a congruence cover for which d x = 9, 
d s = d 124 = 2 700, and lcm (d 1 ,...,d s ) = 604800; when Le Lionnais 
wrote [63], Churchhouse’s example had the largest known value of d x . 
(Erdos had conjectured that d x could be arbitrarily large. His conjecture 
remains open, and carries a $1000 reward for the solver. A cover with 
d x = 40 and s « 10 50 has recently been found [73].) 

What other properties does 604800 have, besides the two that were 
featured by Le Lionnais.'' For this question mathematicians can now 
turn to Neil Sloane’s wonderful On-Line Encyclopedia of Integer Se- 
quences [83], or OEIS, which tells us for example (in sequence A053401) 
that there are 604800 seconds in a week. Sequence A001715 of the OEIS 
reminds us that 604800 = 10!/3!; from this fact we can conclude, with 
a hint from A091478, that exactly 604800 simple graphs on 5 labeled 


146 Selected Papers on Fun and Games 


vertices have 7 labeled edges. Furthermore we learn from sequences 
A055981, A058295, A060593, and A080497 that 604800 is the number 
of ways to write an 11-cycle as the product of two 11-cycles on the same 
elements [16], and that 604800 can not only be expressed as 5! 7! and as 
12!/d(12!) but also as 

(1x2x3x4x5x6x7x8x9x10x11)/(1+2+3+4+5+6+7+8+9+10+11) 

and — via prime numbers — as 

(17 - 2)(17 - 3)(17 - 5)(17 - 7)(17 - 11)(17 - 13). 

Altogether the number 604800 appears explicitly in 78 sequences of the 
current OEIS list, or at least it did when I wrote this essay in November 
2009; thus it possesses 78 “OEIS properties.” I can well imagine that 
Marshall Hall, who was my Ph.D. advisor long ago, would have been 
delighted to drive an automobile whose license plates bore the property- 
rich number 604800. 

These considerations beg us to ask, “What numbers greater than, 
say, 10000, have the most OEIS properties?” I posed this question to 
Sloane in 2001, and he told me how to answer it by downloading a 
stripped version of the database. The champion numbers in November 
2009, by this criterion, are shown in Table 1. 


Table 1 . Numbers > 10000 with the most OEIS properties 


value 

props 

value 

props 

value 

props 

value 

props 

value 

props 

16384 

646 

15625 

415 

59049 

337 

10080 

301 

524288 

278 

65536 

638 

1048576 

387 

131072 

328 

100000 

291 

4194304 

258 

32768 

621 

19683 

365 

46656 

321 

531441 

288 

11111 

255 

262144 

577 

16777216 

360 

1000000 

316 

14641 

288 

16807 

254 

40320 

508 

2097152 

348 

362880 

305 

10001 

282 

117649 

250 


Several conclusions can readily be drawn from this table. First, we 
notice that the magic number 65536 of Figure 1 is right up there, nearly 
tied for the lead. Second, almost all of these property-rich numbers 
are round in G. H. Hardy’s sense: They are “the product of a consid- 
erable number of comparatively small factors” [52, page 48], The only 
exceptions are 10001 and 11111, which are oriented to radix-10 notation. 
Indeed, all of the other champions are powers of 2, 3, 5, 6, 7, 10, or 11, 
except for 8!, 9!, and 10080 (which is twice 7!). 

Table 1 ranks a number n by counting only the sequences in which 
the OEIS database lists n explicitly, it doesn’t count all the sequences to 


Mathematical Vanity Plates 147 

which n actually belongs. For example, A005843 is the sequence of even 
numbers, which explicitly lists only 0, 2, 4, 6, , 120; a number like 

604800 is even but doesn t have the OEIS property of evenness. Being 
near the beginning of a sequence seems to make membership stronger, 
because the fact that 2 is even is noteworthy for 2 but the fact that 120 
is even is basically “duh” for 120. 

Therefore I tried another experiment in which the successive val- 
ues of each OEIS sequence are assigned weights 1, 1/2, 1/4, 1/8, 
Table 2 shows the integers that currently are most important by that 
criterion, and again 65536 ranks near the top. Here the tendency to 
prefer “roundness” is even more pronounced than before: Every number 
in Table 2, with the exception of 10001, is a power of 2, 3, 5, 6, 7, or 10. 


Table 2. Numbers > 10000 with the heaviest OEIS properties 


value weight value weight 


value weight 
262144 27.9 
16777216 27.6 
65536 22.5 
531441 21.5 
59049 20.8 


value weight 
19683 20.4 
15625 19.8 
1048576 18.6 
16384 18.5 
46656 18.2 


387420489 15.1 
32768 15.1 
390625 13.5 
68719476736 13.5 
4194304 13.2 


78125 13.2 
16807 13.1 
823543 12.9 
177147 12.6 
117649 12.1 


value weight 
10001 11.8 
9765625 11.6 
100000 11.6 
2097152 11.3 
1679616 11.0 


I’m willing to admit that such numbers are important. Yet somehow 
the criteria used to generate Table 1 and Table 2 leave me unsatisfied 
from the standpoint of license-plate desirability. One reason is that many 
of the OEIS sequences are not really very interesting at all, propertywise. 
For instance, the Hall— Janko number 604800 occurs near the beginning 
of A002677, but only because it’s the denominator of an obscure constant 
called M3 11 [82]. Frankly, I couldn’t care less. 

Numbers are often in fact especially interesting when they’re at the 
end of a sequence, not the beginning. For example, 65537 is interest- 
ing because it’s the largest known Fermat prime (A092506, A019434); 
43112609 is interesting because it’s the binary length of the largest prime 
number presently known, (11 . . . 1) 2 [94]. (Fans of 43112609 can’t use 
it on a license plate, however, except in North Carolina, because it is 
eight digits long.) I imagine that Richard Brent’s favorite number is 
1568705, which is currently the last element of A064411, because he was 
surprised to discover it in the continued fraction for e 7 [17]; remarkably, 
this 7-digit value arises rather early on, as the 4294th partial quotient 
of a number that probably isn’t rational. 

In my own case, if I had had a chance to choose my favorite 5-digit 
number to put on a license plate in 1969, shortly after I had seen the plate 


148 Selected Papers on Fun and Games 

in Fig. 1, my choice would not have been 65536; I would definitely have 
chosen 12509 instead. Why? Because I had just completed extensive 
calculations leading to the conclusion that 12509 is the smallest n such 
that l(n) < l*{n), where l{n) is the length of the shortest addition 
chain for n and l* in) is the length of the shortest “star chain” (see 
[53, §4.6.3]). Before I had done these computations, such integers were 
known to exist because of a theorem due to W. Hansen [51], but the 
smallest example that could be based on his proof technique was the 
gigantic value n = 2 6103 + (2 1016 + 1)(2 2032 + 1). At once 12509 became 
my favorite 5-digit number. 

I bet Neill Clift’s favorite 8-digit number is 30958077, because he 
has discovered [24] that it’s the least n such that l(n) — l(2n) = l{An). 

Incidentally, the largest integer in the California list [20] was 
9G00G0L, namely 9 x 10 10 °. But it was trumped by ALEPH0 and ALEPH1. 

Computer Science 

In my day job I profess to be a computer scientist, not a mathemati- 
cian, although there is definitely a soft spot for mathematics in my 
heart. Thus my closest colleagues have a computer-oriented rather than 
math-oriented perspective in their predilections for personalized plates. 
For example, Gio Wiederhold drives D8ABASE. Vaughan Pratt chose 
DUELITY, because his work makes considerable use of DUALITY (which 
was already taken when he tried to get it) and because his duality also 
applies to games. 

The most famous license plate from Stanford’s Computer Science 
Department is undoubtedly the one by which the late Gene Golub aptly 
described himself: 


API 

p 

— v 

i CALIFORNIA PR 

RDFSVD 

!. PUTnwm UEXUS.C Dm ; 


Figure 14. An inspiration. 


This much-photographed plate, now his epitaph, highlights the leading 
roles that he played with respect to the computation, application, and 
popularization of the singular value decomposition of rectangular matri- 
ces. Matrix fans also probably know about Jack Dongarra’s Tennessee 
plate, LAPACK, commemorating the popular package of linear algebra 



Mathematical Vanity Plates 149 

routines to which he has made many contributions. (In fact, he previ- 
ously owned LAPACK in Illinois, and LINPACK in New Mexico before that.) 

The most celebrated problem of theoretical computer science — “Is 
P equal to NP ? should probably show up on the highway too. But 
at present nobody has voted either for P EQ NP or for P NEQ NP, at least 
not in California or Massachusetts or New York or in any other state 
that I checked. (W ith two cars, you could hedge your bet and acquire 
both plates.) 

The California list of 1981 [20] included some lowbrow computer- 
related examples such as A HACK, ALGOL 60, CODER, HACKERS, HACKIT, 
I CMPUTE , I COBOL, PC SALES; also TEXWEB, which startled me when I 
spotted it during a visit to Marin County in 1984. By 1986, a car 
bearing PC WIDOW was already on the road in the East [34]. 

Armando Stettner, an engineer at Digital Equipment Corporation 
(DEC) who was working on the UNIX® operating system, decided in 
1983 to get New Hampshire license plates that said UNIX. People in 
those days were clamoring for software licenses that would allow them 
to use this proprietary system legitimately, so he convinced DEC to 
make mock “UNIX licenses” to be handed out at conventions. These 
souvenir plates became wildly popular [75], 

As I was writing the present essay I happened to see the Califor- 
nia license UPSTART, which microcomputer pioneer Lee Felsenstein has 
owned since he created a “startup” in 1986. I also came across TURING1, 
proudly driven by the Computer History Museum curator Dag Spicer. 
Dag told me that TURING itself was unavailable when he made his choice. 

I’ve also heard about two clever vanity-plate ideas based on pro- 
gramming languages, both of which happen to be presently available 
in California. The first one, DO 4 TRAN, will be readily understood by 
any FORTRAN programmer. But the second, 4TH*IF H, needs a bit of 
explanation: It means “Honk (H) if you love Forth,” in perfectly decent 
Forth-language syntax (when followed by THEN). 

I must confess that, when I was following a car several years ago 
whose rear license read ENOFILE, it took me a minute to realize that the 
driver wasn’t necessarily a programmer. 

Somebody in California is now driving an automobile whose license 
reads CDR CAR. Maybe it’s a man named Charles Dudley Robinson. But 
I hope it’s actually a LISP programmer, ideally one who knows also 
that the left and right halves of a machine word, when LISP was first 
implemented on the IBM 704 computer, were obtained by the respective 
instructions CDR (contents of the decrement field of a register number) 
and CAR (contents of the address field of a register number). 


150 Selected Papers on Fun and Games 

Other plates refer to computer graphics, or to the Internet, or to 
user interfaces, artificial intelligence, robotics, networking, texting, etc. 
But that’s a topic for another essay, to be published perhaps in the 
Information Technological Intelligencer. 

Untapped Possibilities 

Eugene Miya [72] recently came up with an idea for a brand new species 
of vanity plates: We can cite the Library of Congress catalog numbers 
of our favorite books. For example, QA1 18 denotes the accumulated 
proceedings of the International Congress of Mathematicians; QA3 A57 
signifies the Memoirs of the American Mathematical Society. Tutte’s 
book on graph theory [88] is QA166 T8; and QA73 E23 is a beautiful 
picture-book about computer history [33]. 

The only trouble with this scheme is that most catalog numbers 
don’t fit on the plates. To cite QA300 P62 (Polya-Szego [78]), you have 
to live in an 8-character state like New York. Furthermore, the most 
recent library numbers usually include decimal points; you must live in 
Colorado, Connecticut, Louisiana, or North Carolina to cite them. The 
only book of my own that I could cite in California is Til K57 [59]. 

To complete my survey, let me now list a few more potential vanity 
plates that occurred to me as I was preparing this essay, together with 
their availability status in various states: 



AZ 

CA 

MA 

MI 

NC 

NY 

SD 

UT 

WV 

0 ZIP 

yes 

yes 

— 

yes 

yes 

no 

yes 

yes 

yes 

TI3V0M 

no 

no 

— 

no 

no 

no 

no 

no 

yes 

WHENIM64 

— 

— 

— 

— 

yes 

no 

— 

— 

yes 

0X0045 

no 

yes 

— 

yes 

yes 

yes 

yes 

yes 

yes 

451 F 

yes 

no 

— 

— 

yes 

yes 

yes 

— 

yes 

F 451 

no 

— 

— 

yes 

yes 

no 

yes 

— 

yes 

CAB1729 

yes 

yes 

— 

yes 

yes 

no 

yes 

yes 

yes 

10E9999 

yes 

yes 

— 

yes 

yes 

yes 

yes 

yes 

yes 

1/0=INF 

— 

— 

— 

— 

yes 

— 

— 

— 

— 

AMS ORG 

yes 

yes 

yes 

yes 

yes 

yes 

yes 

yes 

yes 

DEGAUSS 

yes 

yes 

— 

yes 

yes 

no 

yes 

yes 

yes 

GOFIGURE 

— 

— 

— 

— 

no 

no 

— 

— 

yes 

GOTMATH 

no 

no 

— 

no 

no 

no 

yes 

yes 

no 

TEXHAX 

yes 

yes 

yes 

yes 

yes 

yes 

yes 

yes 

yes 

WAVELET 

yes 

no 

— 

yes 

yes 

no 

yes 

yes 

yes 


(Here “yes” means that it’s available, subject to approval; “no” means 
that it’s not available; “ — ” means that it has improper format with 
respect to letters and/or digits and/or punctuation.) 


Mathematical Vanity Plates 151 


Other Countries 

Canada began to catch the US-style vanity plate craze in the 1980s, 
beginning in Ontario and Prince Edward Island, where motorists had 
already been allowed to choose their own standard- format letters and 
numbers since 1973 [81], By 2007, about 3% of all Canadian plates 
were vanitized [66] — not counting the provinces of Quebec and New- 
foundland/Labrador, which have so far held out against such freedom 
of choice. (Quebecois can, however, display anything they want on the 
fronts of their cars; the official plates appear only in back.) 

Ontario s vanity plates allow up to 8 characters, but they are subject 
to special restrictions in order to enhance readability by law enforcement 
officials [74]: The letters A, S, G are respectively equivalent to the digits 
4, 5, 6; and 0 is equivalent to both 0 and Q. Thus the license 666SAGAS 
would preclude 255 others such as GG65A645, and 

00G00G0L 

would preclude 971 lookalikes. Furthermore, you can’t have more than 
four equivalent characters in a row, as in GRRRRR or XXXXXXX. 

Nothing like the US or Canadian freedom to vanitize is possible in 
England, where the number plates are subject to severe syntactical re- 
strictions. Britishers do, however, sometimes try; for example, a popular 
singer named Jess Conrad reportedly once threatened a duel in Regents 
Park in order to acquire the plate JC21 [8], 

When Britain introduced auto registration in 1903, Bertrand Rus- 
sell’s older brother Frank famously waited in line all night so that his car 
could be identified as A1 [76]. (He later became Under-Secretary of State 
for Transport, responsible for abolishing British speed limits.) More re- 
cently, the comedian Jimmy Tarbuck was known for driving COM 1C; 
hairstylist Nicky Clarke owns H41 RDO; James Bond could be 13 OND; 
and a yellow Mercedes convertible supposedly says ORG 45M [70] . 

Such nonrandom combinations have been sold at auction by the 
Driver and Vehicle Licencing Agency since 1989, beginning with 1A, 
which cost £200,000 at the time. By 2008 these sales had contributed 
more than £1,300,000,000 to the British government treasury [32], 

Once issued, British license plates can subsequently be resold and 
transferred to other vehicles. Indeed, the Cherished Number Dealers 
Association oversees a thriving industry with more than 150 traders 
of registration marks, and a driver recently paid £440,625 for FI [93], 
Somebody claims to have reserved LI NUX in 1993, and L7 NUX was being 
auctioned in 2001 [15]. 


152 Selected Papers on Fun and Games 

Similar remarks apply to licenses in Germany, although without the 
auctions. Therefore I was astonished and thrilled when the plate 

■Hh 1X20091 

was presented to me as a surprise gift several years ago, after I’d given 
some lectures about the MMIX computer at the University of Applied 
Sciences in Munich. Indeed, the German prefix MM is available only in 
a small nearby village, where one of my hosts happened to have the 
connections necessary to acquire this miraculously perfect combination 
on my behalf. Notice also the elegant typography. 

Vanity plates, American style, have however spread to the northern 
shores of Europe, beginning in Scandinavia. I think Sweden was first, 
in 1993 or so, followed soon after by Finland, Denmark, and Iceland. 
Norway will begin to issue personlige bilskilt in 2010 [10]. Meanwhile 
Latvia, Poland, Luxembourg, Slovenia, and even Austria have jumped 
on the bandwagon. Rumor has it that the Netherlands will be vanitized 
next. Will their plates have room for WISKUNDE? 

At the opposite end of the world, “true” vanity plates do exist 
nowadays in Australia, New Zealand, and Hong Kong; they have also 
occasionally been issued in the Philippines for special events. Japanese 
motorists live with a rather bizarre system in which they have freedom 
only to choose a serial number from 1 to 9999, leading to license plates 
of the forms . . .a, . .ab, . abc , or ab-cd , where a, 6, c, and d are digits 
with a/0. Furthermore, cd is never 42 or 49, because those numbers 
connote “death” or “bitter death” in Japanese. (In Japan the fact that 
<p( 49) = 42 is bad news.) Beginning in 1999, monthly lotteries were held 
for the 26 most popular numbers . . . s, . sss, s0-00, ss-ss, 12-34, and 
56-78, where s € {1, 2, 3, 5, 7, 8}; this list was later decreased to only 13 
entries. If you want one of the other values, you can pay extra to get 
your favorite. (See [11].) 

On the continent of Africa one can reportedly obtain vanity plates 
in Liberia and Uganda [85]. 

But South America is still holding out. Indeed, US-style vanity 
plates seem to be presently unavailable anywhere in Latin America 
except in Puerto Rico, where they are called tablillas especiales per- 
sonalizadas. 


Mathematical Vanity Plates 153 

Conclusion 

We ve seen that vanity-plate fever is sweeping through many parts of 
the world, and that this phenomenon presents remarkable challenges 
to mathematicians. One of the main unresolved problems is to deter- 
mine the integers of 5 to 8 digits that are most “interesting,” in some 
reasonably mathematical sense. 

As I did this research I learned about six or seven available plates 
that would suit me well and make me happy. 1 could now, for instance, 
actually obtain Figure 2. But unfortunately I have only one car, and 
I can’t decide which of the plates to live without. So I guess I’ll just 
continue to fantasize about the possibilities. 

Acknowledgments 

The networking skills of Eugene Miya were especially helpful in bring- 
ing many choice examples to my attention, and I’ve also been helped 
by dozens of other people in casual conversations about the subject. 
Andrew Turnbull provided important historical information, including 
reference [85]. David Bailey, Dave Bayer, Carol Bohlin, Laurence Bre- 
vard, David Eisenbud, Michel Goemans, Ron Graham, Victor Miller, Bill 
Ragsdale, and Cathy Seeley contributed photos. Gay Dillin of NCTM 
sent details of the 2005 contest. The four- author n photograph was taken 
by Raul Mendez. I found the PROF SVD image on Wikimedia Commons, 
where it had been posted by Da Troll. 

References 

[1] “City car tag sales off,” The New York Times (15 February 1955), 

[2] “Office keeps tab on state vehicles,” Los Angeles Times (18 Decem- 
ber 1955), A5. 

[3] “First new California plates appear,” Los Angeles Times (6 Decem- 
ber 1962), Al. 

[4] “BUM rap arrives from Folsom,” Los Angeles Times (4 January 
1963), 3. 

[5] “Plates spell home town,” Los Angeles Times (17 September 1967) 
SG_A2. 

[6] “ZAP, POW auto plates fight smog,” Los Angeles Times (22 August 
1970), 20. 


154 Selected Papers on Fun and Games 

[7] “Couple to get first personalized auto plate,” Los Angeles Times 
(26 October 1970), A2. 

[8] “New use for personalized auto plates — fighting smog,” The New 
York Times (5 March 1972), S27. 

[9] “Playful plates: Connecticut tags identify owners,” Life 31,23 (3 
December 1951), 133. [Twenty examples are shown, including PAPA 
STOP MAMA FAST.] 

[10] “Lag ditt egen bilskilt!” http://www.aftenposten.no/spesial/ 
article2736061 .ece [published 27 October 2008, updated 27 May 
2009; accessed November 2009], [This article illustrates the sample 
plate JEG=007 (“I am 007”); in 1981, [20] had already contained ten 
variations of 00FDAH.] 

[11] (My Japanese friends helped me to find this information at http: 
//www. numberplate-m.com/study/choose.html, and in the arti- 
cle on Japanese license plates at http://ja.wikipedia.org/wiki/ 
after searching the latter site for ‘56-78’.) 

[12] D. H. Bailey, J. M. Borwein, P. B. Borwein, and S. Plouffe, “The 
quest for pi,” The Mathematical Intelligencer 19, 1 (Winter 1997), 
50-57. 

[13] David Bailey, Peter Borwein, and Simon Plouffe, “On the rapid 
computation of various polylogarithmic constants,” Mathematics 
of Computation 66 (1997), 903-913. 

[14] David Bayer and Michael Stillman, “On the complexity of com- 
puting syzygies; computational aspects of commutative algebra,” 
Journal of Symbolic Computation 6 (1988), 135 147. 

[15] Robert Blincoe, “LINUX number plate for sale; or is that L7NUX - 
sneaky,” http : //www . theregister . co . uk/2001 /08/ 21 / llnux_ 
number_plate_for_sale/ [accessed November 2009]. 

[16] G. Boccara, “Nombre de representations d’une permutation comme 
produit de deux cycles de longueurs donnees,” Discrete Mathemat- 
ics 29 (1980), 105-134. 

[17] Richard P. Brent, “Computation of the regular continued fraction 
for Euler’s constant,” Mathematics of Computation 31 (1977), 771- 
777. 

[18] Laurence C. Brevard, personal communication (18 August 2009). 

[19] Mel Brooks and Buck Henry, Get Smart (1965-1970), a series of 138 
television episodes starring Don Adams as Agent 86 and Barbara 
Feldon as Agent 99. 


Mathematical Vanity Plates 155 

[20] State of California, Department of Motor Vehicles, Environmental 
License Plate Numbers (21 July 1981), 2 volumes. 

[21] State of California, Department of Motor Vehicles, “DMV mile- 
stones (major events affecting drivers, vehicles, and the DMV),” 

http: / / www.dmv.ca.gov/ about /prof ile /milestones. htm [ac- 
cessed November 2009]. 

[22] F. R. K. Chung and R. L. Graham, “Quasi-random set systems,” 
Journal of the American Mathematical Society 4 (1991), 151-196. 

[23] R. F. Churchhouse, “Covering sets and systems of congruences,” in 
Computers in Mathematical Research , edited by R. F. Churchhouse 
and J.-C. Herz (Amsterdam: North-Holland, 1968), 20-36. 

[24] Neill Michael Clift, “Calculating optimal addition chains,” Com- 
puting 91 (2011), to appear. 

[25] Dennis R. Cowhey, What Does That Mean? The Personal Sto- 
ries Behind Vanity License Plates (Arlington Heights, Illinois: Key 
Answer Products, 1994). 

[26] Matt Cunningham, “A bumper crop of physics plates,” Symmetry 
5,3 (August 2008), 22-27. [Leon Heller, who owns NUCLEON, says 
that his friends think it means “Nuke Leon.”] 

[2*] Robert E. Dallos, “States reap profit on auto vanity plates,” Los 
Angeles Times (3 September 1977), 1. 

[28] Jean-Marie De Koninck, Those Fascinating Numbers (Providence, 
Rhode Island: American Mathematical Society, 2009). 

[29] Joan Dektar, “This year’s great gift adventure,” Los Angeles Times 
(6 December 1970), T16-T22. 

[30] John and Barbara Dixon, The Plate Book: Puzzle Plates —The 
New American Hi-Way Graffiti (Seattle: Voler, 1982). 

[31] C harles R. Donaldson, “Almost anything goes on new personalized 
license plates,” Los Angeles Times (6 September 1970), SF_Al. 

[32] James Duddridge, “Sale of registration marks,” Hansard House of 
Commons Debates 482 (5 November 2008), columns 256-258. [At 
this time Duddridge introduced a bill to permit American-style van- 
ity plates in England, but his proposal never received a second 
reading.] 

[33] Charles & Ray Eames, A Computer Perspective (Cambridge, Mas- 
sachusetts: Harvard University Press, 1973). 

[34] Faith W. Eckler, “Vanity of vanities,” Word Ways 19 (1986), 195- 
198; “All is vanity,” Word Ways 20 (1987), 141-143. 


156 Selected Papers on Fun and Games 

[35] Robert Enstad, “‘Peace’ license plate issued,” Chicago Tribune (28 
October 1970), 3. 

[36] Paul Erdos, “On integers of the form 2 k +p and some related prob- 
lems,” Summa Brasiliensis mathematicae 2 (1950), 113-123. 

[37] Ian Fleming, Casino Royale (London: Jonathan Cape, 1953). [This 
novel contains nontrivial mathematics relating to gambling, besides 
its characters Le Chiffre and Mathis. CHIFFRE is currently available 
in California.] 

[38] Gordon Garb, personal communication (5 August 2009). 

[39] Martin Gardner, “A fanciful dialogue about the wonders of nu- 
merology,” Scientific American 202, 1 (January 1960), 150, 152, 
154, 156. Reprinted as Chapter 1 of The Numerology of Dr. Matrix 
(New York: Simon & Schuster, 1967). 

[40] George Garrigues, “TAG problems? NOT at THE DMV,” Los 
Angeles Times (13 January 1963), WS9. 

[41] Michel X. Goemans and David P. Williamson, “Improved approx- 
imation algorithms for maximum cut and satisfiability problems 
using semidefinite programming,” Journal of the Association for 
Computing Machinery 42 (1995), 1115-1145. 

[42] Solomon W. Golomb, “Run-length encodings,” IEEE Transactions 
on Information Theory IT-12 (1966), 399-401. 

[43] Solomon W. Golomb, Robert E. Peile, and Robert A. Scholtz, Basic 
Concepts in Information Theory and Coding: The Adventures of 
Secret Agent 00111 (New York: Plenum, 1994). 

[44] Dave Graham, Those Crazy License Plates (Los Angeles: Price/ 
Stern/Sloan, 1974). I 

[45] Ronald L. Graham, personal communication (28 July 2009). 

[46] Gordon Grant, “Hundreds of motorists seek ego-soothing license 
tags,” Los Angeles Times (29 August 1970), Dl, D14. 

[47] Gerry Griffin, “New Hampshire license plate museum,” panel 3, 
http://nhlpm.eom/3.html [accessed November 2009], 

[48] Gerry Griffin, “New Hampshire license plate museum,” panel 53, 
http://nhlpm.com/53.html [accessed November 2009]. 

[49] David Haber, “California license plate info,” http : //www . calpl8s . 
com/cpinfo .html [accessed November 2009]. 

[50] David Haber, “California black base plates,” page 3, http : //www . 
calpl8s. com/ calif ornia/black. html ?pg=3 [accessed November 
2009], 


Mathematical Vanity Plates 157 

[51] Walter Hansen, “Zum Scholz-Brauerschen Problem,” Journal fur 
die reine und angewandte Mathematik 202 (1959), 129-136. 

[52] G. H. Hardy, Ramanujan: Twelve Lectures on Subjects Suggested 
by His Life and Work (Cambridge, England: Cambridge University 
Press, 1940). 

[53] Donald E. Knuth, Seminumerical Algorithms, Volume 2 of The 
Art of Computer Programming (Reading, Massachusetts: Addison- 
Wesley, 1969). 

[54] Donald E. Knuth, Surreal Numbers: How Two Ex-Students Turned 
On to Pure Mathematics and Found Total Happiness (Reading, 
Massachusetts: Addison-Wesley, 1974). 

[55] Donald E. Knuth, TpjX: The Program, Volume B of Computers & 
Typesetting (Reading, Massachusetts: Addison-Wesley, 1986), 2. 
[Versions 3.14, 3.141, 3.1415, 3.14159, 3.141592, 3.1415926 were 
released respectively in 1991, 1992, 1993, 1995, 2002, 2008.] 

[56] Donald E. Knuth, “Teach calculus with Big O” Notices of the 
American Mathematical Society 45 (1998), 687-688. 

[57] Donald E. Knuth, MMIX: A RISC Computer for the New Millen- 
nium, Volume 1, Fascicle 1 of new material for The Art of Computer 
Programming (Upper Saddle River, New Jersey: Addison-Weslev 
2005). 

[58] Donald E. Knuth, Combinatorial Algorithms, part 1: Volume 4A 
of The Art of Computer Programming (Upper Saddle River, New 
Jersey: Addison-Wesley, 2010). 

[59] Donald E. Knuth, Tracy Larrabee, and Paul M. Roberts, Mathe- 
matical Writing (Washington, District of Columbia: Mathematical 
Association of America, 1989). 

[60] David Larsen, “Words you can’t drive by,” Los Angeles Times (20 
January 1970), Bl, B8. 

[61] David Larsen, “Personal tags — a bumper crop,” Los Angeles Times 
(25 November 1970), Cl, C8. 

[62] David Larsen, “Gasoline plan’s odds may favor the evens,” Los 
Angeles Times (10 May 1979), B3, B32. 

[63] Frangois Le Lionnais, Les Nombres Remarquables (Paris: Hermann 
1983). 

[64] Tien-Yien Li and James A. Yorke, “Period three implies chaos,” 
American Mathematical Monthly 82 (1975), 985-992. 


158 Selected Papers on Fun and Games 

[65] Greg Lindberg and Dave Smith, “Connecticut License Plates,” 

http : // ctpl8s . tripod . com/id9 . html and also . . . id20 . html [ac- 
cessed November 2009]. 

[66] Stefan Lonce, “WHZ SO VN? [Who’s so vain?]” Move 12,4 
(Fall 2007), 20-24. See also http://www.lcns2rom.com/vanity- 
platesurvey.htm [accessed November 2009], 

[67] Megan Luther, “A license to make a statement: S.D. drivers speak 
their minds,” Argus Leader (25 October 2009), appendix, http:// 
www . argusleader . com/assets/pdf /DF1451091023 . PDF [accessed 
November 2009]. 

[68] Andy Magid, “Mathematics and the public,” Notices of the Amer- 
ican Mathematical Society 51 (2004), 1181. 

[69] Massachusetts Department of Transportation, Registry of Mo- 
tor Vehicles, “History of the plate,” http://www.mass.gov/rmv/ 
history/ [accessed November 2009], 

[70] MB club UK, discussion forum at http://www.mbclub.co.uk/ 
forums/ general-discussion/ 11074-anyone-seen-any-good- 
number-plates-cars-lately.html [accessed November 2009, by 
which time this discussion thread included 6114 postings con- 
tributed since 2004, arranged on a total of 408 webpages], 

[71] Colman McCarthy, “A PLATE 2 CALL YOUR OWN,” The Wash- 
ington Post Times Herald (2 March 1969), Potomac magazine, 
25-27. 

[72] Eugene N. Miya, personal communication (8 November 2009). 

[73] Pace P. Nielsen, “A covering system whose smallest modulus is 40,” 
Journal of Number Theory 129 (2009), 640-666. 

[74] Ontario Ministry of Transportation, “Personalized licence plates,” 
http : / / www . mto . gov . on . ca/english/ dandv/ vehicle /plates . 
shtml [accessed November 2009], 

[75] The Open Group, “The history of the UNIX® license plate,” http : 
//www. unix.org/li cense-plate.html [accessed November 2009], 

[76] Richard Ottaway, “Vehicle registration marks bill,” Hansard House 
of Commons Debates 458 (23 March 2007), columns 1101-1120. 

[77] Grisha Perelman, “The entropy formula for the Ricci flow and its 
geometric applications,” http://arXiv:math.DG/0211159. 

[78] G. Polya and G. Szego, Aufgaben und Lehrsatze a us der Analysis, 
first American edition (New York: Dover, 1945). 


Mathematical Vanity Plates 159 

[79] George Reasons, “No FUN on new license plates; bills go out this 
week, so PAY,” Los Angeles Times (23 December 1962), C13-C14. 

[80] Art Ryon, “A license plate to remember,” Los Angeles Times (21 
March 1963), A6. 

[81] Joseph P. Sallmen, “Canadian personalized license plates,” http: 
//www. canplates.com/vanity.html [accessed November 2009]. 

[82] Herbert E. Salzer, “Tables of coefficients for obtaining central dif- 
ferences from the derivatives,” Journal of Mathematics and Physics 
42 (1963), insert facing page 163. 

[83] Neil J. A. Sloane, The On-Line Encyclopedia of Integer Sequences, 

http://www.research.att.com/~njas/sequences [accessed No- 
vember 2009]. 

[84] Don Snyder, “La Canada man given NO SMOG car plates,” Los 
Angeles Times (11 November 1970), SG6. 

[85] Tim Stentiford, “Vanity: Born in the USA, tales from the tail-end,” 
Plates 54,4 (August 2008), cover, 21-26. 

[86] Peter P. Szabaga, “Vanity plates,” http://pages.prodigy.net/ 
pizzabagel/VanityPlates_AlphaList .htm [accessed November 
2009], 

[87] Gay Talese, “State unit urges car law changes,” The New York 
Times (16 January 1959), 12. [This article, incidentally, contains 
the earliest known printed occurrence of the phrase vanity plates.) 

[88] W. T. Tutte, Connectivity in Graphs (Toronto, Ontario: University 
of Toronto Press, 1966). 

[89] UTAH.GOV services, “Personalized license plates,” http://dmv. 
utah.gov/licensepersonalized.html [accessed November 2009], 

[90] Vermont Department of Motor Vehicles, “A history of Vermont 
license plates 1894-2000,” http: //dmv. Vermont. gov/registra- 
tions/ drivers/plates/history/ [accessed November 2009]. 

[91] Herbert J. Vida, “New personalized licenses have message of 
PEACE,” Los Angeles Times (27 August 1970), WS1. 

[92] David Wells, The Penguin Dictionary of Curious and Interesting 
Numbers (Harmondsworth, Middlesex, England: Penguin Books, 
1986). 

[93] David Wilkins, “3ND OF TH3 R04D?” in The Independent (10 
November 2008), motoring section [available online in November 
2009], 


160 Selected Papers on Fun and Games 

[94] George Woltman, “Great Internet Mersenne Prime Search GIMPS,” 
http://www.mersenne.org/ [accessed November 2009], 

[95] Alexander J. Yee and Shigeru Kondo, “5 trillion digits of pi- new 
world record,” http://www.numberworld.org/misc-runs/pi-5t/ 
details.html [accessed November 2010], 

Addendum 

In the present book I can’t resist mentioning a related factoid that 
I omitted from the essay above because it would probably not have 
been understood by mathematically oriented readers: The license plates 
POTRZB and NGOGN are still unclaimed in California. 

Professor Matt Kahn of Stanford’s Art Department chose IOIOI for 
purely aesthetic reasons: He likes this pattern’s fourfold symmetry. 

Several computer-science-related tidbits have also come to my at- 
tention: 

• Eugene Miya owns a sequel to the UNIX® plate: 


E£ OR DIE 1 

LINUX 


• British computer scientist Alex Tiskin has spotted PRO 5ESR. 

• Steve Johnson once had California YACCMAN. 

• John Warnock or Chuck Geschke should think seriously about ac- 
quiring X708798. 

And the story continues: I spotted * LG LG LG on 7 June 2010. 


Chapter 18 


Diamond Signs 


[Excerpted from a website that was launched in September 2003.] 

During our summer vacation in 2003, my wife and I amused ourselves 
by taking leisurely drives in Ohio and photographing every diamond- 
shaped highway sign that we saw along the roadsides. (Well, not every 
sign; only the distinct ones.) For provenance, I also stood at the base of 
each sign and measured its GPS coordinates. 

This turned out to be even more fun than a scavenger hunt, so we 
filled in some gaps when we returned to California. And we intend to 
keep adding to this collection as we drive further, although we may have 
to venture to New England in order to see FROST HEAVES. 

Oui collection is limited to signs that appear in a diamond shape, 
even though many other interesting signs exist. After all, it’s necessary 
to draw the line somewhere. In spite of this restriction, we’ve spotted 
and documented more than 1000 different signs as of June 2010. 

This hobby adds spice to my travel experiences, and tends to keep 
me alert while driving. But I must admit that I’m sometimes thinking 
Hmm. . . Do I have that sign? rather than “Should I slow down?” 

Traffic engineers have official manuals that dictate what they should 
be doing. However, our purpose has not been to record the recommended 
practices; we have instead tried to capture the situation that actually 
exists on America’s highways and byways. As a result, we keep finding 
new constructions that essentially represent a kind of creative “folk art” 
that varies greatly from one community to another. 

I’ve tried to organize the collection by introducing an ad-hoc num- 
bering scheme, roughly like the “Dewey decimal system” used to classify 
the books in older libraries. Each sign has a code name; for example, 
"I55b is number 55b in the class of signs related to Intersections. 

The following pages contain a small sampling of what we’ve seen so 
far, emphasizing examples that have unusual and/or noteworthy aspects. 


161 



162 Selected Papers on Fun and Games 

Arrows 


A05 A06 A09 



N41°30.623' W81°36.77X' N41°11.706' W83°34.276' N37°27.265' W122°09.18l' 


A16 A29 A35 



N41°30.54l' W81°36.885' N37°25.386' W122°08.920' N41°28.043' W81°S7.073' 



Signs A05, A06, and A09 illustrate the three basic changes of direction: 
curves, bends, and turns. Bends are rare; but we happened to spot A06 
on 6 August 2003, the day we began our quest! In 2006 I found a left 
bend to go with this right bend, and in May 2010 I finally saw reverse 
bends such as A16. The double turn, A29, occurs right near our house; 
I’ve actually never seen it elsewhere. Could it be unique? We spotted 
the exotic loop A35 in Ohio and the traffic circle A84a in Oregon. Two 
or three freeways merge in A92 or A92a. 











Diamond Signs 163 



Arrows with Numbers 

BOOa 


N37°09.856' W121°59.446' 


N37°21.675' W12X°55.153' 


N41°58.031 / W121°54.891 


California traffic engineers often indicate the speed for which a curve or 
turn has been designed: “Slow down to 50 for this curve; take this turn 
at only 10 miles per hour.” But sometimes, as in BOOa and B66, a curve 
is marked only 5 while a turn is rated as high as 40. Unusual speeds 
( BO la) occasionally help to get a driver’s attention. There are reverse 
curves (B81), reverse turns (B86), and winding roads (B90). Exit ramps 
have dramatic curves in two styles, illustrated here for left turns by B26 
and B41. And then there’s the famous tipping truck (B93). 













164 Selected Papers on Fun and Games 

Critters 


CIO C12 C25b 



N37°26.698' W119°39.192' N39°30.167' W1X5°57.563' N35°01.196' W107°19.805' 

C52 C49 C31b 



N39°45.658' W105°39.408' N19°48.860' W155°58.312' N37°20.700' W122°60.01l' 

C55 C60 C71 



N36°32.202' W121°54.727' N41°07.424' W122° 19.513' N37°53.184' W122°37.583' 


The iconic road signs for animals rank high among everybody’s favorites. 
We find contented cows (CIO), as well as steers who are wilder (C12). In 
these images the animals are almost always shown facing left — although 
Arizona signs show elk facing both ways. My favorite elk sign, shown 
here, is New Mexico’s version (C25b). I spotted bighorn sheep (C52) in 
Colorado. Sometimes whimsical additions appear: a burro with a hula 
hoop (C49), a duck with a bindle (C31b). California has boars (C55) and 
bears (C60). Let’s also not forget the smaller critters, like newts (C71). 












N40°00.182' W83°07.930' N43°02.158' W87°58.962' N41°16.68l' W81°38.224' 




D08 


D93 


D09 


N37°25.419' W122°09.900' N42°21.672' W71°05.376' N37°26.248' W122°09.229' 


When roads are being repaired, traffic has to adapt, so new signs some- 
times arise and disappear overnight. Special kinds of arrows, like D89, 
are used only in this context. We found the flamboyant D86 on a Milwau- 
kee freeway. I first encountered D78, which is a symbolic version of D44, 
on 22 May 2010. Sign DIO shows a “flagger,” who here is holding a stop 
sign instead of a flag. The special sign D59 appears only during Stanford 
football games. Bicyclists have detours too (D08). Temporary lanes are 
often narrow (D93). The good news is that detours do end (D09). 











166 Selected Papers on Fun and Games 

Entrances 


E80 E13 E40 



N37°25.637' W122°04.676' N43°02.728' W88°02.672' N41°07.79l' W83°28.198' 

E45 E70 E05 



N40°51.18l' W83°39.08l' N40°44.042' W80° 10.741' N41°26.529' W81°56.088' 

E95a E90 E65 



N41°08.103' W82°41.246' N41°26.472' W81°56.158' N38°15.638' W122°26.416' 


Warning signs can also alert drivers to unusual sources of traffic or other 
activity. E80 is hinged so that it morphs into another when no con- 
cert is in progress. E13 illustrates one of many ways to warn about 
emergency vehicles. Some signs say HOSPITAL ENTRANCE, CHURCH 
ENTRANCE, SCHOOL ENTRANCE, etc.; E40, E45, E70, and E05 are 
less common instances of this genre. The wording can be tricky: Do 
foreigners understand that E95a and E90 mean the same thing, or that 
PLANT ENTRANCE (E65) has nothing to do with horticulture? 











Diamond Signs 167 


Intersections 


H6a I21a 136 



N41°25.169' W82°37.87l' N37°36.158' W122°23.468' N41°03.76l' W81°31.297' 


Mathematicians use the symbols +, H, and T in theorems; drivers, 
however, use them to anticipate configurations of crossroads. Many ex- 
otic variations on this theme can be found, including I16a, I21a, and 
monstrosities like 136. Sometimes a circle indicates that one or more of 
the side roads is a dead end (I08c, 107, 109). Railroads add yet another 
dimension, as in 152 and 175; in fact, a rail crossing near my wife’s birth- 
place was the very first item in our collection. I once made a special trip 
to Akron, Ohio, in order to photograph the “crossing yield” sign, 199. 











168 Selected Papers on Fun and Games 

Lanes 


L10 LlOa L08 



N41°02.37l' W83°39.323' N37°26.266' W122°09.28l' N41°30.22l' W81°38.010' 

L45a L42 L51 



N41°30.089' W81°39.017' N41°34.987' W122°11.338' N37°27.572' W119°S4.987' 

L57 L43a L93 



N41°21.277' W81°37.256' N40°12.766' W105°14.374' N37°48.328' W122°28.420' 


The symbolic sign L10, intended to mean “right lane ends” or “lane ends 
merge left,” was found to be misleading; so it is scheduled to be phased 
out and replaced by a new design (LlOa) borrowed from Canada. I still 
haven’t seen a replacement for the inverse variant L08. Do drivers under- 
stand L45a, where lanes are being split under a bridge? Narrow lanes are 
best described in words, as in L42, L51, and L57. My daughter found 
and photographed the remarkable L43a. Sign L93 appears near the 
Golden Gate bridge; a policeman was unhappy that I photographed it. 











Nonspecific 


Diamond Signs 169 



N25 N51 N57 




N41°30.345' W82°02.713' N37°20.498' W122°01.808' N37°20.435' W121°57.313' 


Some signs say simply DANGER or CAUTION or SLOW; N16 is more 
emphatic, and N18 has flashing lights. Sign N19, located within the 
grounds of a cemetery, is the only one in my collection with white let- 
ters on black. Several other classes of more-or-less generic signs are 
exemplified by N25, N51, and N57. Speed-limit signs are supposed to 
be rectangular, but lately they’re being enclosed in diamond frames as 
in N41. The cities of Sunnyvale (N92) and Santa Clara (N95) try to keep 
drivers alert by introducing unique signs, changed every few months. 












170 Selected Papers on Fun and Games 

People 


P04 Pile P84 



N36°59.814' W122°03.827' N37°58.749' W122°33.864' N41°25.515' W82°21.499' 

P53 P51 P57 



N37°24.110' W122°05.415' N37°24.657' W122°09.473' N37°27.70l' W122°11.267' 

P62 P65 P74 



N40°00.80l' W82°54.736' N41°30.359' W81°33.577' N41°24.875' W81°36.226' 


The image of a pedestrian crossing the street is perhaps the most com- 
mon warning sign of all. Here I show two variants: a jogger (P04) and 
a musician (Pile). We found the clever sign P84 in a summer resort 
where I used to go as a child. Speaking of children, my collection in- 
cludes more than a dozen ways to warn about kids playing; my favorite 
so far is P53. The designers of P51 and P57 were careful not to refer to 
SLOW CHILDREN. People with disabilities are protected by a variety of 
signs such as P62, P65, and P74. 











Road Status 


Diamond Signs 171 





N37°39.650' W122°04.114' N40°00.560' W105°15.845' N34°17.99l' W108°08.013' 

R79 R73a R75 


N37°48.092' W122°24.462' N41°18.798' W83°10.076' N38°04.62l' W121°43.990' 

R24 R26 R43 


R17 


R04 


R06 


Special hazards arise in difficult terrain. For example, hills are particu- 
larly dangerous for trucks (R17) and bicycles (R04). My daughter has 
also encountered another type of hill- warning sign f R06) . Sharp curves 
and/or the lack of shoulders at the edges of a highway correspond to a 
number of interesting warnings such as R79, R73a, and R75. On the 
other hand, artificial hazards are often created as “traffic c almi ng” de- 
vices to reduce a driver’s speed: A HUMP (R24) is theoretically milder 
than a BUMP (R26); there’s even a negative bump (R43). 


N37 32.177' W122°17.324' N37°33.246' W122°00.850 / N40°15.374' W105°51.362' 











172 Selected Papers on Fun and Games 

Temporary 


T12 T10 T18 



N37°22.167' W121°55.653' N37°25.79l' W122°10.539' N41°23.167' W83°39.646' 

T46 T72 T77 



N35°11.605' Wlll°37.218' N41°29.336' W81°55.573' N37°25.826' W122° 10.510' 

T95 T39 T04a 



N37°31.320' W122 0 15.973' N41°28.704' W81°57.614' N37°38.315' W121°02.009' 


Signs that used to say MEN WORKING (T12) have mostly been replaced 
by non-sexist versions such as T10 and T18. Repair-related signs are dif- 
ficult to capture, since they come and go quickly; there’s often lots of 
traffic and no good place to park. Thus I was lucky to snap T46 while 
traveling in Arizona, even though the sign itself was dirty and worn. 
Other short-lived hazards include partially patched pavement (T72, 
T77) and electrical wiring (T95). These extra hassles for motorists can 
be accompanied by frank, though unfriendly, signs like T39 and T04a. 











Diamond Signs 173 


Vehicles 


V04g V20 V15a 



N37°25.675' W122°11.418' N38°32.697' W121°44.305' N40°30.17l' W83°41.732' 

V40a V42 V51 



N37°24.558' W121°57.186' N37°48.277' W122°25.244' N40°36.165' W80°32.798' 


Stanford University has introduced a series of signs like V04g, hoping 
to avoid car-bike crashes. Another famous Stanford sign (V20), now 
historic, once greeted visitors to the site of the Artificial Intelligence 
Laboratory in the hills above the campus. Other vehicles to watch out 
for, in various parts of the world, are snowmobiles (V15a), golf carts 
(V16), forklifts (V17), horse-drawn buggies (V18), trams (V40a), and 
cable cars (V42). My wife and I were recently pleased to discover West 
Virginia’s nice symbol for school bus stops (V51). 











174 Selected Papers on Fun and Games 

Weather 


W14 W27 W47 



N37°27.24l' W121°55.258' N36°13.190' W117°15.642' N39°47.233' W105°46.919' 

W31a W37 W32 



N39°07.175' W108° 19.544' N39°02.89l' W119°56.797' N37°21.83l' W122°10.128' 

W60 W67 W80 



N39°23.475' W115°30.272' N35°31.642' W105°14.147' N36°37.427' W121°50.62l' 


Water, snow, and ice coexist rather precariously with automobiles when 
drivers aren’t careful. Motorists must watch out when turning in the 
rain (W14), and we’d better keep out of deep water too (W27). After I 
stopped to photograph W47 in a Colorado blizzard, my car got stuck in 
the snow and the wheels spun without effect. Icy roads are particularly 
risky (W31a, W37, W32). Of course water isn’t the only source of 
weather-oriented woes: There are enough rocks to scare Chicken Little 
(W60, W67), not to mention winds and sand (W80). 











Diamond Signs 175 


What Does It Mean? 


L45 R66a R67a 



N37°28.714' W122°13.27l' N39°59.63l' W105°15,580' N37°46.965' W122°25.264' 


Two iconic warning signs of the 1990s were withdrawn after 2000 be- 
cause people couldn’t understand them. But they haven’t completely 
disappeared: My wife snapped NARROW BRIDGE (L45) in 2004, and 
in 2009 she found not only PAVEMENT ENDS (R66a) but also its inverse 
(R67a). Other examples of signs in my collection that are slightly less 
than scrutable are the seismic-retrofit sign at the San Francisco-Oakland 
Bay Bridge (T35), the flying biker (R54b), the barred intersection (L59), 
the Shasta Street puzzle (A75), the cryptic V71a, and the rebus-like P18. 










176 Selected Papers on Fun and Games 

The Online Collection 

All of the diamond signs that I’ve documented appear on the Web at 

www-cs-f acuity . Stanford . edu/~knuth/diamondsigns/diam.h.tml 

and pages reachable from there. One of the interesting aspects of this full 
set is the variety of ways in which the same concept has been expressed. 
For example, I’ve come across seven different ways to warn motorists 
about possibly being blown away: 


W70 W71 W72 W73 W74 W75 W76 



And there’ve been 14 ways to tell drivers that they can’t enter certain 
roads without backtracking and going out the same way they came in: 

L80 L80a L80b L80c L80d L80e L81 



L81a L82 L82a L83 L84 L84a L84b 



Each sign on my website has its own page, which presents a full color 
image of 900 x 900 pixels together with the GPS coordinates and other 
information about where and when the picture was taken. There also 
are summary pages with thumbnail images of all the signs that belong 
to the individual classes A, B, C, . . . , W. Several interesting signs from 
Canada and other countries are included on separate pages. 

The website is arranged something like a simple adventure game, 
where you can find hidden delights by clicking in appropriate places. 
For instance, if you explore carefully you’ll discover where a bridge 
that was said to have clearance 12' 8" in 2003 was later reported to 
have only 12' 6" of clearance; some trucks evidently got stuck in the 
meantime. You'll see occasional graffiti. And you’ll find examples of 
unintentional humor, like PREPARE TO STOP WHEN FLASHING and 
CAUTION PEDESTRIANS SLIPPERY WHEN WET. 




Diamond Signs 177 



One of my favorite pictures in this collection is best viewed online, so 
I didn’t show it above. Traffic engineers in Sonoma County, California, 
have used an ordinary symbolic “merging traffic” sign, A91, and rotated 
it by 90° at a prominent intersection, giving sign number A91a in my 
collection. (As far as I know, this rotated sign doesn’t appear anywhere 
else in the world.) You might think that I cheated here, by simply 
rotating A91 and pretending to have a new sign; but if you look closely, 
you 11 see that a bird is perched at the top of A91a, thereby proving 
its authenticity! I didn’t actually notice the bird when I was hastily 
snapping the picture; I first saw it only while preparing the image for 
the Web a few days later. It’s one of the few cases where I didn’t crop 
the picture and force it into a standard diamond-only shape. 

Closeup inspection of some of the images will reveal beautiful tex- 
tures produced by weathering. For example, 196 is particularly attrac- 
tive; by chance, I happened to capture it just a week before Stanford’s 
transportation department replaced it by a brand new sign. The new 
sign is perhaps more effective, but it isn’t as lovable; it has the more 
modern design that I’d previously photographed as 195. Another sign 
with venerable texture, R47, will perhaps be appreciated by fans of the 
Wild West — it’s riddled with bullet holes. 

Most of the pictures were taken by my wife or by myself, or by mem- 
bers of our family. But some of the rarer signs have been contributed by 
friends; for example, among the images above, B26, B66, C55, C71, D93, 
P04, V40a, and W80 were photographed by Yoichi Hariguchi; C49 and 
W27 by Peter Eichenberger. The first sign that I received from afar, in 
September 2003, was the wonderful SEE WE TOLD YOU SO sent from 
Iowa by Nate Holbrook (N90). He said that he found it a block or so 
away from another sign that said BRIDGE OUT AHEAD. 



178 Selected Papers on Fun and Games 

A cool interface between all of these signs and Google Maps, created 
by Brian Cornell, has been available since December 2007. You can find 
if by going t° the bottom of the webpage cited above and clicking on 
‘see where the signs were photographed’. 


Let me close with a sign that was spotted by Barry Hayes in Ithaca, 
New York, in 1990. Although it’s not a diamond sign, I cannot resist 
including it in the present book: 



Chapter 19 


The Orchestra Song 


[An unpublished composition for concert band , dated 8 December 1954.] 

This piece is actually a “nine-part invention” : It is the result of nine 
solos all playing at once. 

The band has been divided into nine sections, marked by Roman 
numbers I IX. First section I plays alone. Then section II plays alone. 
Next comes a duet between sections I and II. Then section III plays 
alone, followed by sections, I, II, and III together. Thus, the piece is to 
be played in the following order: 

A. Section I solo 

B. II solo 

C. I and II 

D. Ill solo 

E. I, II, and III 

F. IV solo 

G. I, II, III, and IV 

H. V solo 

I. I, II, III, IV, and V 
.1. VI solo 

K. I, II, III, IV, V, and VI 

L. VII solo 

M. I, II, III, IV, V, VI, and VII 

N. VIII solo 

O. I, II, III, IV, V, VI, VII, and VIII 

P. IX solo 

Q. I, II, III, IV, V, VI, VII, VIII, and IX 

R. full band (explained below) 

[The full score is too large to fit the format of this book. So it has been 
divided into four parts, which appear on the next four pages.] 


179 





182 Selected Papers on Fun and Games 


i-Aii „ F— 

> > > > 

1 1 , — == 

> 

>L 9 — 

-] - t : ■ r 

j — — 1 



j i rn i i rn — — — — — — 

- F — riii — 

^ J-J * 

:=± ^ 4 . • t 1 1 11 t r~d r i - 4 — F 

r-d — 

' €-) crisply . . 

9 0 € 

P 1 P'P i-p- p-p- p- 

i / — i — hh — r l r i i kLLrr 

1/0 \ 

^ 1 


-^5 t 

' fj gaily 

0 „ n rr 


1 k rr — - 

n rm 

/ _J|L| — £ i 

ijztI 

i m -1 i — F 

n — — • — d J i 


-mM. _ J 1 

m* 0 \ 9 d -J— 

4 m 9 d J 

1 -to v — u d J 

3^ m T ^ 1 

m * - 

4 — m d 

t 3 m _ i ^ r— 

J O boldly 

^ 


f- f f 7 (•. 


f 1*1=1 3 1 II VP n 1 PPF — 


4-0 LTF 

L — p 4 

1 V ' ! 

^ = 


All instruments use the first ending in parts A-Q. 

Part R: In the final part, the whole band plays the pickup note forte 
and sustains it for four beats. (The trumpet and piano, which have two 
pickup notes, use only the first.) 

Then, suddenly pianissimo, the chorus is repeated again, building 
up volume with a slow crescendo and, using the second ending, finishing 
fortissimo. 

Although the score is only ten measures long, it is expanded by these 
repeats to 144 measures. No dynamic shading is marked on the score 
because it changes several times during the piece; the conductor should 
explain it while practicing. 

Extra parts: E b Clarinet plays the Flute I part. Alto Clarinet plays the 
Baritone Sax part. Bass Trombone plays the Bass part. English Horn 
plays the Oboe part. Xylophone or Marimba play the Piano part. Bells 
play the Flute part. 

Addendum 

I played tenor saxophone in the band at Lutheran High School in Mil- 
waukee, Wisconsin, during my freshman, sophomore, and junior years, 
after having taken piano lessons while in elementary school. After awhile 
I became interested in learning about the other instruments, and I looked 
at the music they were playing, so I began to read books about orches- 
tration that I found in Milwaukee’s Public Library. 



The Orchestra Song, written near the beginning of my junior year, 
was my first attempt to put that theory into practice. At the top of my 
original manuscript I wrote 

THE ORCHESTRA SONG Traditional Austrian Song 
— adapted for band by Don Knuth 

I had learned to sing a variant of most of these melodies at summer camp 
during the 1940s, with voices imitating instruments, and it occurred to 
me that real instruments would also work well. Here was a perfect vehicle 
for me to try my hand at writing band music, as a first test case. I also 
had in mind that many Milwaukeeans would know the song well enough 
to enjoy hearing this version, if we could perform it at our annual spring 
concert in Milwaukee Auditorium. 

So I took the verse whose words were “The violin’s playing ... a 
lovely song” and assigned it to the saxophone section. (Our school had 
only a concert band, not an orchestra.) The other parts that I knew from 
camp - “The clarinet . . . goes dua-dua-dua-det” ; “The horn . . . wakes 
me at morn” ; “The trumpet . . . goes trump-et-ta-ta-ta-ta-ta ta” ; “The 
drums . . . five five five five one” ; and “The bassoon it knows the point of 
counterpoint . . .” — all fit nicely with the instruments we had available, 
except that I moved the bassoon theme to the piano, where I thought 
it would work better. I supplied simple new themes for the oboes, the 
flutes, and the bassoons/basses, so that everybody was included. 


184 Selected Papers on Fun and Games 

I laboriously copied out all the parts with pen and ink. Even though 
I needed to copy only ten bars in each case, I recall that this process 
took an incredibly long time. (We had quite a large band, more than 
80 players.) I wondered how real composers could possibly get whole 
symphonies prepared for a full orchestra. 

Well, it turned out that our band director was not at all impressed. 
He gave me no encouragement whatsoever, and never found time to 
rehearse any of the parts. So I chalked it up to experience and moved 
on to other pursuits, having recently discovered MAD comics. 

In retrospect I do think that the arrangement looks reasonably good, 
at least on paper, but of course I’ve never had a chance to actually hear 
it. (On second thought, I should probably have changed the final chord 
of the second ending: As it stands, the “dominant” tone — namely C in 
the key of F — is played only by the piano! Was I joking?) 

Many different versions of this traditional folk tune are prevalent. 
For example, I learned later that my future wife had learned five of 
the six verses I knew, when she had gone to summer camps in Ohio, 
although with slightly different words. While preparing this chapter 
for publication in 2009 I discovered a seven- verse version by Julius G. 
Herford [Humor in Vocal Music (New York: Hargail Music Press, 1946), 
4-5] , with nice parts for flute and bassoon that I had never encountered 
before; he called it “The Instruments.” German versions, with words 
such as “Die Geige, die singt, sie jubelt und klingt; Die Klarinett, die 
Klarinett, macht duaduadua gar so nett,” etc., again with numerous 
variations, are often attributed to Willy Geisler. 


Chapter 20 


Gnebbishland 


[The opening bars of the piano score for an unpublished musical comedy 
skit, dated 10 April 1959 and performed on 18 April 1959.] 

I belonged to the local chapter of Theta Chi fraternity at Case Institute of 
Technology, and Case ’s Interfraternity Council used to put on an annual 
talent show /competition called Stunt Night. During the spring semester 
of my junior year, I wrote the script, lyrics, and music for a short musi- 
cal playlet that was our stunt for 1959. The following recollections were 
written in 2009 as I was preparing the present book for publication. 

The title, “Gnebbishland,” came from cartoon characters called 
Nebbishes that were wildly popular at the time. Thousands of 
stationery stores all over America were selling greeting cards 
that featured these clueless but amiable characters, with 
mottos like “I’m trying to be nice” or “So?” or “No, I’m 
more repressed than you are.” One image alone — two 
couch-potato Nebbishes who say “Next week we’ve got 
to get organized” — reportedly sold more than 750,000 
copies. [See Leonard Gross, “A Nebbish can’t do any- 
thing! . . . except set the whole country laughing and 
make a fortune for the college boy who draws him!” This 
Week Magazine (16 February 1958), 21, 23.] The man 
who created Nebbishes, Herb Gardner, went on to write 
widely acclaimed plays and films such as A Thousand Clowns 
(1962) and I’m Not Rappaport (1985). 

College students of this era were having Nebbish parties and electing 
Nebbish queens. My idea was to depict a world of Nebbishes in which 
the characters sing about their lifestyle and valiantly resist an attempt 
to change it. All live happily ever after. 

Unfortunately (or mercifully?) all copies of the original script and 
lyrics seem to have disappeared. The only artifact still in my files is the 
piano score, of which the first one-third is reproduced here. 



185 


186 Selected Papers on Fun and Games 










188 Selected Papers on Fun and Games 

I’m including Gnebbishland in this book because I’ve always liked 
the main chorus, which begins at the place marked [Aj and was sung to 
the following words: 

I’m a Gnebbish, and a Gnebbish isn’t snobbish — 

A little slobbish — 

But it’s Fun bein’ that way! 

As kings of the greeting card industry, 

We’re all on the verge of insanity. 

Everybody sang the chorus; then, in the places where the score indicates 
first, second, and third endings, the company would break into individual 
solo numbers, in which each character sang a short phrase found on 
cards that were currently in local stores. The only such phrase that I 
still remember for sure is the one beginning at bar 3 of the third ending, 
where an appropriately costumed creature tries to dance, and sings this: 


> 


/ 




T 

I ain’t 

neat . . . but I’m 

— m 

swe 

Pa 

:e- eel 

a 

A 

±3=1= 


The rest of the score isn’t worthy of revival, so I’ll just summarize it 
here. Much of it is soft background music, interspersed with stretches of 
dialog; I quoted extensively from MacDowell’s “To a Wild Rose” when 
preparing that part. 

There were two additional songs, only one of which has left any 
traces in my memory after fifty years. That one was sung by the anti- 
hero, a well-meaning but uptight outsider who tries, in the play, to 
reform the natives but realizes the error of his ways. The climax occurs 
as he sings, “Alas, I was wrong; they were happy when I came. Now all 
that is gone — and it’s me that is to blame!” Here I borrowed the tune 
of “La Seine” by Guy Lafarge (1948), which was well known in America 
at the time because it had been given new English words ( “You will find 
your love in Paris”) by Mack Gordon. 

The melody of the other song was probably original with me. But 
I no longer recall it, so it can’t be worth much. It just goes in one ear 
and out the other when I play it. 

I’ve always loved to compose and to play music. Thank goodness 
I never have needed to make a living from this delightful avocation. 


Chapter 21 


A Carol for Advent 


[A song based on words by Jill Knuth, sent to friends with our pre- 
Christmas letter in December 2001.] 

“Carols” — songs written to celebrate the birth of Jesus Christ and the 
spirit of love and generosity that has long been associated with the Christ- 
mas season — are among the most delightful songs in the popular cultures 
of many lands. We begin to hear these familiar tunes each year in late 
November and throughout the month of December. 

But Christians who grew up with a strong liturgical tradition, like my 
wife and myself, prefer not to sing Christmas carols until December 2), 
"Christmas Eve, ” because the four weeks preceding Christmas Day are 
traditionally a time of preparation and waiting, called Advent. 

That leaves us with four weeks in which there ’s a relative dearth of 
special songs to sing. Therefore Jill was inspired to write the words to 
an Advent Carol, “A Baby is Promised. ” A few months later, I set her 
words to music, with four-part harmony (soprano, alto, tenor, bass); and 
we sent it to our friends in time for the Advent season of 2001. 

One can, of course, sing the verses in unison, preferably with piano 
accompaniment (at least until the harmonies become familiar). 

This piece is dedicated to our grandsons, Rees Levi Tucker, Carter 
John Knuth, Kevin Don Knuth, and Kadin Morris Tucker, two of whom 
were born between the time we wrote it and the time we shared it. 

When we first sent out the music we suggested that people might 
enjoy looking up the following Bible verses: 2 Kings 6:33, Isaiah 30: 18, 
Luke 2 : 25. 

Incidentally, Jill has also designed and made a dozen or so inspiring 
banners that are especially appropriate for the days of Advent. They are 
discussed in the first 23 pages of her book Banners Without Words (San 
Jose, California: Resource Publications, 1986). 


189 


190 Selected Papers on Fun and Games 

A Baby is Promised 


Jill and Don Knuth 


1 It’s De- 

2 We’re 

3 The 

4 He’s 


nr r r r r 


cem- ber al- read- y, There’s so much to 

har- ried, we’re tired, Con- fused and hard- 
world is bro- ken And frac-tured and 

here! * He’s here! * The gift from a- 


) be 

)ur 

hat 

te’s 


r- 


ver 

get 

through? 

A 

Ba- by 

is 

for 

some 

rest. 

A 

Ba- by 

is 

he 

be 

born? 

A 

Ba- by 

is 

mise 

and 

love. 

The 

Ba- by 

long^ 


wwa 




A Carol for Advent 191 


pro-mised, 

A 

Sa- vior, 

the 

Word! 

But watch-ing 

is 

pro-mised, 

A 

Sa- vior, 

the 

Word! 

But watch-ing 

is 

pro-mised, 

A 

Sa- vior, 

the 

Word! 

But watch-ing 

is 

pro-mised, 

The 

Sa- vior, 

the 

Word! 

* Watch-ing 

is 


wear- 1 - some 
wear- i- some 
wear- i- some 






193 


I noticed similar effects when I was experimenting years ago with the de- 
sign of computer-generated typefaces for the printing of beautiful books. 


Chapter 22 


Randomness in Music 


[Unpublished notes based on an informal talk given on 9 May 1990.] 


John Chowning once asked, me to speak for a few minutes to the Stan- 
ford Music Affiliates, a group of people representing the companies who 
were helping to sponsor the research at CCRMA, Stanford’s Center for 
Computer Research in Music and Acoustics. Here is a reconstruction of 
approximately what I said, based on the slides that I used at the time. 


Patterns that are perfectly pure and mathematically exact have a strong 
aesthetic appeal, as advocated by Pythagoras and Plato and their in- 
numerable intellectual descendants. Yet a bit of irregularity and unpre- 
dictability can make a pattern even more beautiful. I was reminded of 
this fact as I passed by two decorative walls while walking yesterday from 
my home to my office: One wall, newly built, tries to emulate the regu- 
lar rectangular pattern of a grid, but it looks sterile and unattractive to 
my eyes; the other wall consists of natural stones that fit together only 
approximately yet form a harmonious unity that I find quite pleasing. 


An ugly new wall 


A delightful old wall 


194 Selected Papers on Fun and Games 

A design somehow “came to life” when it was not constrained to be 
rigidly consistent.* 

Similar examples abound in the musical realm as well as in the world 
of visual images. For example, I’m told that people who synthesize mu- 
sic electronically discovered long ago that rhythms are more exciting if 
they don’t go exactly “1, 2, 3, 4” but rather miss the beat very slightly 
and become what a mathematician might call “1 + dj, 2 + <5 2 , 3 + 83 , 
4 + 64 .” Although the discrepancies 8 mount to only a few milliseconds, 
positive or negative, they enliven the music significantly by comparison 
with the deadly and monotonous pulsing that you hear when the <5’s are 
entirely zero. 

Singers and saxophone players know better than to hit the notes of 
a melody with perfect pitch. 

Furthermore, we can take liberties with the “ideal” notes themselves. 
In an essay called “Chance in artistic creation,” published in 1894, f 
August Strindberg recounted the following experience: 

A musician whom I knew amused himself by tuning 
his piano haphazardly, without any rhyme or reason. 
Afterwards he played Beethoven’s Sonate Pathetique 
by heart. It was an unbelievable delight to hear an 
old piece come back to life. How often had I previously 
heard this sonata, always the same way, never dreaming 
that it was capable of being developed further! 

And the notion of planned imperfection is not limited to variations 
in the performance of a given composition; it extends also to the choices 
of notes that a composer writes down. The main purpose of my talk 
today is to describe a way by which you could build a simple machine 
that will produce random harmonizations of any given melody. 

More precisely, I’ll show you how to produce 2 n + 2 n ~ 1 different 
harmonizations of any n-note melody, all of which are pretty good. A 
machine can easily generate any one of them, chosen at random, when 
its user plays the melody on a keyboard with one hand. 

The method I shall describe was taught to me in 1969 by David 
Kraehenbuehl (1923-1997), when I audited his class on Keyboard Har- 
mony at Westminster Choir College. It is extremely simple, although 


* See, for example, my book Digital Typography , pages 57-59, 286-287, 324- 
325, 386, 391-396; also The METRFONTbook, pages 183-185. 

f Auguste Strindberg, “Des arts nouveaux! oil Le hasard dans la production 
artistique,” Revue des Revues 11 (15 November 1894), 265-270. 


Randomness in Music 195 


you do need to understand the most elementary aspects of music theory. 
I shall assume that you are familiar with ordinary music notation. 

Kraehenbuehl’s algorithm produces four-part harmony from a given 
melody, where the top three parts form “triadic” chords and the bottom 
part supplies the corresponding bass notes. 

A triad is a chord that consists of three notes separated by one-note 
gaps in the scale. Thus the triads are 


H~'8 g 


¥ § » 


and others that differ only by being one or more octaves higher or lower. 
The bottom note of a triad is called its “root,” and the other two notes 
are called its “third” and its “fifth.” 

These notions apply to any clef and to any key signature. For ex- 
ample, with the treble clef and in the key of G major, the seven triads 


y 8 » § 11 § t 


are known by more precise names such as a “D major triad,” etc.; but 
we don’t need to concern ourselves with such technical details. 

The important thing for our purposes is to consider what happens 
when individual notes of a triad move up or down by an octave. If 
we view these chords modulo octave jumps, we see that they make a 
different shape on the staff when the root tone is moved up an octave 
so that the third tone becomes lowest; this change gives us the first 
inversion of the triad. And if the root and third are both moved up an 
octave, leaving the fifth tone lowest, we obtain the second inversion: 

Root position First inversion Second inversion 

= O 8 

= 3 = 

Even though two-note gaps appear between adjacent notes of the first 
and second inversions, these chords are still regarded as triads, because 
octave jumps don’t change the name of a note on its scale: An A is still 
an A, etc., and no two notes of an inverted triad have adjacent names. 

Music theorists have traditionally studied three-note chords by fo- 
cussing their attention first on the root of each triad, and next on the 
bottom note, which identifies the inversion. Kraehenbuehl’s innovation 
was to concentrate rather on the top note, because it’s the melody note. 



196 Selected Papers on Fun and Games 

He observed that each melody note in the scale comes at the top of three 
triadic chords — one in root position (0), one in first inversion (1), and 
one in second inversion (2): 


012012012012012012012 

Furthermore, said Kraehenbuehl, there’s a natural way to add a 
fourth part to this three-part harmony by simply repeating the root 
note, an octave or two lower. For example, in the key of C, we get 


012012012012012012012 



as the four-part harmonizations of melody notes A, A, A, B, B, B 

G, G, G. This rule almost always works well, but like all good rules it 
has an exception: When the bass note turns out to be the leading tone 
of the scale (which is one below the tonic), we should change it to the so- 
called dominant tone (which is two notes lower). Thus Kraehenbuehl’s 
correction to the natural rule yields the 21 four-part chords 


12 0 12 

o 





Randomness in Music 197 


in the key of G, because F c is the leading tone in that case. Notice 
that when the bass note is corrected by shifting it down from a leading 
tone in root position, it produces a chord with four separate pitches (the 
so-called “dominant seventh chord” of its key), so it’s no longer a triad. 

OK, now we know three good ways to harmonize any given melody 
note in any given key. Kraehenbuehl completed his method by pointing 
out that the same principles apply to melodies with any number of notes, 
provided only that we never use the same inversion twice in a row. If 
one note has been harmonized with, say, the first inversion, the next 
note should be harmonized with either the root position or the second 
inversion; and so on. With this procedure there are three choices for the 
first chord, and two choices for every chord thereafter. 

Let’s test his algorithm by trying it out on a familiar melody: 



“London Bridge is falling down, my fair lady” has eleven notes, so Krae- 
henbuehl has given us 3 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 = 3072 ways to harmonize 
it. The binary representations of three fundamental constants, 

7T = 3 + (.00100100001111110110101010001 . . . ) 2 , 
e = 2 + (.10110111111000010101000101100 . . . ) 2 , 

<j>= 1 + (.10011110001101110111100110111 . . . ) 2 , 

serve to define three more-or-less random sequences of suitable inver- 
sions, if we prefer mathematical guidance to coin-flipping. Namely, we 
can use the integer part of the constant to specify the first chord, then 
we can change the number of inversions by +1 or —1 (modulo 3) for 
each successive binary digit that is 0 or 1, respectively. This procedure 
gives us three new harmonizations of that classic British theme: 





Amazing. Kraehenbuehl’s algorithm seems far too simple to be correct, 
yet it really works! 


Of course there’s a little glitch at the end, because we have only one 
chance in three of ending on a chord that’s stable and “resolved.” No 
problem: In such a case we can just repeat the last melody note. With 
this extension, variations 1 and 2 will end nicely with 



I can hardly wait for somebody to build me a keyboard that will perform 
such harmonizations automatically. After all, it’s basically just a small 
matter of programming. 


Chapter 23 


Basketball’s Electronic Coach 


[This material was assembled from documents in my family archives.] 

During all four years of my undergraduate studies at Case Institute of 
Technology between 1956 and 1960, I served as manager of the basketball 
teams, having had several years of experience in that role during my high- 
school days. At first I worked with Case's freshman team coached by Bill 
Sudeck; later I helped the varsity team coached by Nip Heim. 

It was natural for me to combine this activity with my growing in- 
terest in computers; so I worked out a scheme for automating much of 
the work. A letter to my parents, dated 8 February 1958, said, “I’m 
basketball manager again, doing the statistics on the IBM. ” 

In high school I’d come up with a general rule of thumb that said, 
“ Possession of the ball is worth roughly one point, except near the end of 
a period. ” In other words, if you enter the stadium at a time when your 
team is leading by a score of 50~49, the effective score is really 51-f9 if 
your team has the ball, but the game is basically tied if the other guys have 
possession. A corollary of this rule is that field goals don’t really change 
the effective score! One team gains 2 points, but loses possession, while 
the opponents gain possession. The score really changes when there’s a 
turnover, or when a free throw is made, or at the very end. 

Of course I knew that this rule of thumb was only a rough approx- 
imation; maybe possession was worth only .8 of a point, say. Even so, 
the person who steals the ball should be rewarded more than the person 
who makes baskets, contrary to the normal way that players get credit 
for their contributions. 

In college I finally had an opportunity to test these hunches in a 
quantitative way, and the computer program I wrote was based on those 
informal notions about possession. To everyone ’s surprise, including my 
own, the system turned out to be quite successful. 


199 


200 Selected Papers on Fun and Games 

Please keep in mind when reading these notes that the rules of bas- 
ketball have evolved since the 1950s. For example, there was no such 
thing as a 3-point field goal in those days. Also, all Casies were male. 

An Undated Manuscript Written During 1958 

The following is a brief summary of the manner in which basketball 
records are kept by an electronic computer at Case. 

The statistics at each basketball game can be taken by two men: 
a recorder and a spotter. After the game it takes approximately 30 
minutes to prepare the necessary totals from the game sheets and about 
three minutes to punch the IBM cards. One IBM card is made for each 
Case player who participated in the game, plus a card each for Case and 
the opponents. Then the machine takes 1.5 minutes to process the game: 
30 seconds to take in the “program” of instructions for calculation, 30 
seconds to take in the statistical data from all the previous games, and 30 
seconds to take in the statistics from this game and to punch the answers. 
The computer punches four cards for each player, two indicating his 
performance in this particular game and two containing his cumulative 
record to date. The cards can easily be printed up for reference and can 
be filed neatly. Any desired set of statistics can quickly be found from 
them by passing them through a sorter. 

The following information is taken down during the game: 

1. Field goals attempted and made (divided into short, medium, and 
long range). 

2. Total free throws attempted and made. 

3. Last free throws of a set, made and missed. 

4. Total fouls and offensive fouls. 

5. Rebounds, defensive and offensive. 

6. Violations of rules causing loss of ball. 

7. Assists. 

8. Loss of ball by fumble, bad pass, or jump ball. 

9. Gain of ball by interception or jump ball. 

10. Defensive mistakes — allowing opponent to score a field goal. 

11. Minutes played. 

Each of these eleven statistics is kept for the individual Case players, 
and items 1 through 6 are kept for the opponents as a team. 

The computer does routine calculations such as the shooting per- 
centages and the running season totals. It also gives a personal score to 


Basketball’s Electronic Coach 201 

each Case player, assessing how many points he actually contributed dur- 
ing the game, giving due weight to rebounds, fumbles, et al. Of course 
only the recorded statistics are taken into account, not unmeasurable 
quantities like team spirit, or play setup, etc. — although those charac- 
teristics will sway a statistics-taker in the player’s favor when decisions 
have to be made in borderline cases. 

The weightings of all the individual factors will change from game 
to game. For example, if the opponents are deadly on free throws, it is 
more of a sin to commit a foul than if they miss free throws frequently. 
If the other team is not rebounding well defensively, a missed field goal 
is not so costly. Thus, these weightings should be expected to vary 
considerably in different games. 

The computer calculates the “true point contribution” of a player 
by using a rather complicated formula. Using the abbreviations FGA 
(field goals attempted), FGM (field goals made), FTA (free throws at- 
tempted), FTM (free throws made), LFTI (last free throws made), LFTO 
(last free throws missed), TF (total fouls committed), OF (offensive fouls), 
OR (offensive rebounds), DR (defensive rebounds), VIOL (violations), AST 
(assists), FUM (fumbles), BP (bad passes), JL (jump balls lost), JG (jump 
balls gained), INT (interceptions), DM (defensive mistakes), the player’s 
“point contribution” rating is 

PC = 2FGM + FTM + 2(AST - DM) 

- a(VI0L + FUM + JL + BP + AST + FGM + LFTI) 

+ /3(INT + JG + OR + DR + DM - OF) 

- 7 (TF) - S (FGA - FGM + LFTO), 

where a, f3, 7 , and 5 are weighting coefficients determined by team totals. 
In the formulas for these coefficients, small letters indicate opponents’ 
totals and capital letters denote Case totals: 

a = 2f gm/ (f ga + viol + of - or + INT + JG + TF - OF); 

/3 = 2FGM/(FGA + VIOL + OF - OR + FUM + JL + BP + tf - of); 

7 = (ftm - /3(lfti + If to x DR/ (or + DR))) /TF: 

6 = a x dr/(0R + dr). 

Intuitively, a represents the average opponents’ points per chance; this 
number varied widely last season from game to game, from .32 up to 1.02. 
On the other hand (3 represents Case’s average points scored per chance; 
last season this coefficient remained almost the same from game to game, 
showing a slight upward trend. The third coefficient, 7, represents points 
lost per foul; this number also varied drastically. It was as high as +.70 in 


202 Selected Papers on Fun and Games 



FIGURE 1. The mimeographed forms on which I collected data for each period. 
When a player attempted a shot, I wrote his number at his current location. 
(Reduced to 60% of the original size.) 









Basketball’s Electronic Coach 203 


one game, but in two games it was slightly negative ; that is, in those two 
games it actually paid to foul! The final coefficient 5 is the rebounding 
differential at Case’s basket. 

The program is presently designed for an IBM 650 computer, but 
it is readily adaptable to other machines. Copies of the program with 
complete instructions for its use with a 650 may be obtained from the 
Case Computing Center after January, 1959. The project is still in its 
early experimental stages and improvements will undoubtedly be made 
as they suggest themselves. 

Local Newspaper Coverage 

[An article by Bill Scholl in The Cleveland Press (8 March 1958).] 

Electronic Age Creeps Into Case Cage 

When a machine is developed capable of translating the total abilities of two 
teams and their coaches into the final score of an athletic event, chances are 
Case Tech will have it. 

Imagine, no more long bus rides and hours of physical effort for the play- 
ers; no more agonizing seasons of planning, plotting, hoping and wailing for 
coaches; no more parking problems and energy-sapping cheering for the fans; 
no more sports writers — wup! 

Just a brief whirring of wheels, clashing of gears, flashing of lights, ringing 
of bells, and it’s all over. 

Basketball: Atomic A. & M. 72, Sad State 43. 

This age of electronic miracles hasn’t produced such a gadget — but who 
can argue that it won’t? 

While we’re waiting, Case has taken an interim step by putting a large, 
three-unit IBM 650 computing machine to work on a minute breakdown of 
the school’s varsity cage statistics this season. 

In 30 seconds, the machine comes up with figures that would take the 
statistician three hours to work out. 

The innovation is the brainchild of sophomore Don Knuth of Milwaukee, 
who at 6 feet, 5 inches, actually is taller than any of the Case players. 

“I grew too fast and my coordination is poor for basketball,” explains the 
quiet, bespectacled physics and math whiz almost apologetically. 

Don decided to put the computer to work on the growing volume of cage 
statistics after he was asked to devise a formula to rank the players and then 
found it took hours to figure out the results. 

“It’s a pretty complicated formula and takes quite a while to work out by 
hand,” says Don. 

Don is so busy recording the multitude of facts called out by assistant 
Dave Grigsby from their perch behind the Case bench that he doesn’t get to 
see much of the games anymore. 


204 Selected Papers on Fun and Games 



After the final whistle, Don takes his charts to the computing lab a short 
distance from the fieldhouse, punches the data onto cards, and then puts the 
IBM 650 through its paces. Rental fee for the machine is $80 an hour while 
in operation. 

“The biggest delay is getting Don to bring the information back to us,” 
laughs Coach Nip Heim, who admits the computer has been more than a little 
help this winter. 

“The results we got were the determining factors in several changes we 
made between semesters,” says Heim. “That’s when we started (Dick) Kar- 
linger at forward and moved (Jake) Phillips to guard.” 

Case won six games this winter for its best season since 1954-55. 

“We can always pick out the top man, or two,” explains Heim, “but from 
there on down it’s tough.” Knuth’s formula even shows how many points 
a Case player permits the enemy to score by way of his bad passes, double 
dribbles, fumbles, etc. 

“The machine figures out everything except how to put the ball through 
the hoop,” says Bill Sudeck, freshman cage coach. 

Next step will be to send the 1958-59 statistics through a two-million- 
dollar Univac, a gift from Remington Rand now being installed at Case. 

Time marches on. 


[An article by Tom Riley in The Cleveland Plain Dealer (22 December 1958).] 

Mechanical Marvel Helps Case Cage Quintet Click 

“The number of players times a basic fifty plus individual performance ratings 
equal the margin of victory or defeat.” 

That formula is helping to win basketball games at Case Tech, Coach 
Philip (Nip) Heim revealed last night. 




Basketball’s Electronic Coach 205 

Case is an institute of technology and its undefeated basketball team is 
an example of the range of tests and experiments by the students. 

With the aid of the formula planned by team manager Don Knuth, the 
performance of each player is rated by an IBM 650 computor [sic] following the 
game. Knuth, a junior from Milwaukee, takes down the information during 
the game and later feeds it into the machine. 

The number of minutes played, the number of short, medium, and long 
shots attempted and scored, offensive and defensive rebounds, fumbles, bad 
passes, and assists are all poured into the mechanical brain along with the 
important formula. 

Mike Doria, a six-foot, four-inch sophomore from St. Joseph High, and 
Dick Logar, a six-foot, one-inch senior from Lorain, are leading in the ratings. 
Doria, scoring 80 points during the Rough Riders’ five straight victories, was 
given a boost against Ohio Wesleyan Friday night when he registered 27 re- 
bounds. Logar’s 34 points against Mount Union Dec. 17 was a good meal for 
the IBM brain. Logar has tallied 87 points. 

Minutes after the data is filed into the machine, a typewritten sheet evalu- 
ating each player is ready for Coach Heim’s study. The coach knows instantly 
how well each boy performed and where concentrated practice is needed. An- 
other sheet reports the reaction of the opposition to the plays of the Rough 
Riders. 

The aid of the mechanical brain was developed by Knuth, a mathematics 
major, as an experiment in his class. The formula was revised a few times and 
now the computer can tell the coach almost everything except the range of 
morale, which is running high with Case the only undefeated college basketball 
team in the city. 

“We can watch the game and easily evaluate a few players, but it’s al- 
most impossible to check all the boys’ performances during the game,” Heim 
explained. “The machine gives an accurate rundown on every boy that played 
and can even suggest a starting lineup for the next game.” 

The machine’s evaluation suggests at times that a player might do better 
or just as well at a guard position instead of forward, and this information 
proves especially valuable for the Case coaching staff. 

Lacking guards but having ample forwards, Case solved the problem with 
the mechanical brain. Now different players alternate at the position and give 
the squad more depth. 

“Sometimes a player may be down for a game because of an examination 
coming up or some other problem and this can’t be spotted by the machine,” 
Heim pointed out. The mental attitude or errors in a player won’t come out 
in Knuth’s formula, but Heim’s 25 years experience as a coach has taught him 
to spot these things. 

Heim is the first to admit that Case is not a university concentrating 
on athletics. “Sports is a necessity on the curriculum but is secondary to 


206 Selected Papers on Fun and Games 

studies and naturally the students’ interest in their classes ekes out into all 
their activities,” he commented. 

The basketball team’s IBM advisor is a working example of the univer- 
sity’s scope of influence on its student body. 


National Magazine Coverage 

[The following item appeared in Newsweek 53 , 1 (5 January 1959), 63.] 



What’s That About a Score Card? A Computer’s the Thing 

If the nation’s athletic coaches glanced back this week, they would see nothing 
less than the IBM 650 computer coming fast. 

Thanks in part to this electronic brain, Cleveland’s Case Institute of Tech- 
nology basketball team is currently sporting a 5-0 record. “The 650 is an added 
man on my staff,” explained Philip (Nip) Heim, a 25-year-coaching veteran 
now enjoying his best season at Case. 

The IBM 650 “coach” is the brain child of 20-year-old Don Knuth of 
Milwaukee, a mathematics major who is also team student manager. After 
Case’s Rough Riders had lost six of its first seven games last season, Knuth 
told Heim he could come up with a mathematical formula for rating each man 
that embraced eleven different qualities of play in one equation. Also, the 
various functions would be “weighted” for each game. That is, when Case 
played a good rebounding team, the rebound part would get more numerical 
importance. 

At Case’s games Knuth is constantly bent over his charts, so busy he 
literally doesn’t “know what the score is.” After the final whistle, each player’s 
performance is put on punch cards and run through the 650. Within 90 
seconds Knuth has a computer rating for each man in the form of a number 
from minus 5 to plus 20. 

Clearly, the IBM 650 is no substitute for talent. But Heim says it gives 
him a good line on his starting five. There have also been some surprises. 
For the five games played this season, Dick Logar has been high scorer. The 
mechanical coach, however, credited Mike Doria with the highest rating (see 
contrasting totals above). 

Heim naturally is kidded about his new “assistant.” But other coaches 
are now making dead-earnest inquiries. 




Figure 2. Don Knuth ’60 (left) and coach Philip (Nip) Heim 
replay a Rough Rider basketball game in the Computing Center. 

(from Case Alumnus magazine, February 1959) 


National Television Coverage 

IBM Corporation commissioned Stan Russell to make a film that documented 
the whole process, and they supplied the film to the Columbia Broadcasting 
System. The film, entitled “Electronic Coach,” aired on 8 March 1959 as part 
of the Sunday News Special at 11pm on WCBS-TV in New York. Here’s a 
transcript of the sound track, which conformed in most respects to the script 
that Russell had provided: 

Walter Cronkite (shown seated at his desk): Well, something new has 
come to basketball this year — a bit of automation. The men at Case Institute 
of Technology in Ohio still dribble and shoot the ball, of course, but one of 
their machines now decides which one of them will take to the floor. (The film 
was now started.) 

Automation came on the heels of desperation. The Institute won only 
six out of sixteen games last year; so this season, Don Knuth, student 



208 Selected Papers on Fun and Games 

mathematician, used an electronic computer to evaluate 
each player’s performance. 

Here’s how he did it: During the scrimmage, Knuth 
bills the performance record for each player, noting ev- 
erything from baskets to fumbles. This data is put on 
punched cards and fed to an IBM computer capable of 
making 50,000 calculations a minute. Coach Phil Heim 
checks the computer’s findings for the player he needs as 
the strategy changes. 

The material comes off the computer, and then — 
the Game. Now Heim takes a look at those computations 
and decides which substitute goes into the game for the 
immediate strategy. 

Does the system work? Coach Heim thinks it does: 
His team has won 11 out of 14 games this year. 
[Cronkite’s commentary was carried by 64 television net- 
work stations, with an estimated viewing audience of six 
million people. A copy of the film has been archived by 
the Computer History Museum, and it can now be viewed 
on YouTube.] 



Afterthoughts 

Alas, I have been unable to find any copies of the original program, nor 
do I recall who carried on with it after I left for graduate school. 

My formula for PC should not be taken too seriously. I kept fiddling 
with it, and never really believed that it was rigorously correct. This 
work was done long before I had ever heard of Markov processes. 

I communicated details of this work to some people at Marquette 
University in the early 1960s. But it has almost surely had no influence 
on subsequent applications of computers to sports, except perhaps to 
stimulate others to do better. 

By 1995, professional basketball teams were using computers rou- 
tinely. Scott McMurray [“Basketball’s new high-tech guru,” U.S. News 
& World Report 119,23 (11 December 1995), 79-80] described a state- 
of-the-art program called Advanced Scout, designed by Inderpal Bhan- 
dari of IBM Research. 


Chapter 24 


The Triel: A New Solution 


[Originally published in the Journal of Recreational Mathematics 6 
( 1973 ), 1 - 7 .] 

In a well-known problem, three men fight a pistol duel until two of 
them are dead. Since a “duel” usually implies that there are only two 
participants, we may call such a three-way contest a “triel.” 

Here are the rules for a triel: The players draw lots to determine 
who fires first, second, and third. Then they take up positions at the 
corners of an equilateral triangle. Each will fire single shots in turn, 
continuing in the same cyclic order until there is only one survivor. The 
person who is firing may aim at will. 

The traditional problem is to determine the survival probabilities 
for each participant, assuming that (a) all three adopt the best strategy; 
(b) no one is killed unintentionally by a wild shot; (c) the players have 
respective probabilities p, q, and r of hitting whatever target they aim at; 

(d) the values of p, q, and r are positive and known to everyone; and 

(e) the values of p, q, and r remain constant throughout the lives of the 
corresponding players. 

The purpose of this note is to point out that the previous analyses 
of this problem are incorrect, and to give the (rather surprising) correct 
solution. 

1. The Two- Person Case 

After one of the players has succumbed, there will be a duel between the 
two survivors, so we should solve this simpler problem before considering 
the full triel. For convenience in the use of English-language pronouns 
we shall assume that the duelists are both male. Let f(p,q) be the 
probability that the first player survives, when his accuracy ratio is p 
and his opponent’s is q. Clearly 

f(p,q) = P+ (1 -p)(l - f(q,p)); 


209 


210 Selected Papers on Fun and Games 

for if his first shot hits its target he is the winner, otherwise 1 — f(q,p) 
is the probability that he is the winner. It follows that 

f{p, q) = p + (1 -p) (l - (q + (1 - g)(l - f(p, q)))) 

= p+ (1 -p)(l - q)f(jp, q). 

This linear equation has the solution 

f{P,q) = p/(p + q-pq), 

which is (as we might expect) an increasing function of p and a decreasing 
function of q. 

Thus, the two-person case has a simple solution. 

2. The Three-Person Case 

Suppose it’s your turn to shoot in a triel. If you hit your man, the 
other opponent will fight a duel with you, and he will get to shoot first. 
You would be foolish to aim at the weaker player, since your chances of 
hitting the stronger player are equally good. If your shot is successful, 
you are better off eliminating the more dangerous opponent; if your shot 
misses it doesn’t matter who you miss. Therefore you never aim at your 
weaker opponent. 

Let’s assume that the three trielists are named Petersen, Quisling, 
and Rasmussen, and that their respective accuracy probabilities satisfy 
p < q < r. The argument in the preceding paragraph proves that nobody 
will ever aim at Petersen, until one of his opponents is wiped out. Then 
he gets first crack at the other. 

Let P(p,q,r) be the probability that Petersen survives, if he goes 
first and is followed by Quisling, then Rasmussen; let Q(p,q,r) and 
R(p, q, r ) be the corresponding probabilities for Quisling and Rasmussen 
to survive in those same circumstances. Similarly define P(q,p,r) for 
Petersen’s chances when Quisling goes first and is followed by Petersen 
then Rasmussen; etc. If each player aims at his stronger opponent, we 
can write down 18 linear equations that define the situation, starting 
with 

P(p,q,r) =p(l - f(q,p)) + (1 -p)P(q,r,p), 

Q(p,q,r) = pf(q,p) + (1 -p)Q(q,r,p), 

R{p,q,r) = (1 -p)R(q,r,p), 

P(q,p,r) = qf(p, q) + (1 - q)P(p, r, q ) , 


The Triel: A New Solution 211 


and so on. The solution to all these equations is readily obtained, using 
the formula for f(x,y) given above; but the formulas are too complex 
to reproduce here. 

Since the initial order is obtained by drawing lots, we obtain the 
overall survival probabilities by averaging over each of the six possible 
arrangements. This gives the rather complicated, but exact, answers 


_ / (6 — 3g — 3r + 2qr)p 2 (l — q) (6 — 3p — 3r + 2 pr)pq 
V p + q-pq P^rq — pq 

(6 — 3p — 3q + 2 pq)pr 


+ 


p + r — pr 

_ / (6 - 3g - 3r + 2qr)pq (6 - 3p - 3r + 2pr)q 2 (l - p) 

V p + q-pq p + q-pq 

R _ f (6-3p — 3q + 2pg)r 2 (l-p) 


)/ 


D, 


Q 


)/ 


(*) 


D, 


V 


p + r — pr 


-)h 


where D = 6(1 - (1— p)(l — g)(l — r)). A glance at these equations does 
not make the behavior of the solution very transparent, so the following 
table of typical values may be helpful: 


TABLE 1. Examples of the probabilities in (*) 


p 

Q 

r 

P 

Q 

R 

0.2 

0.4 

0.6 

.314 

.305 

.381 

0.2 

0.4 

0.8 

.273 

.237 

.490 

0.2 

0.4 

1.0 

.237 

.182 

.581 

0.2 

0.6 

0.8 

.246 

.337 

.417 

0.2 

0.6 

1.0 

.220 

.268 

.512 

0.2 

0.8 

1.0 

.203 

.354 

.443 

0.4 

0.6 

0.8 

.430 

.304 

.266 

0.4 

0.6 

1.0 

.403 

.249 

.348 

0.4 

0.8 

1.0 

.374 

.322 

.304 

0.6 

0.8 

1.0 

.513 

.303 

.184 


Notice that in some of these cases the weakest player has the best chance, 
while the strongest player has the worst, even when he is a “sure shot” ! 
There’s an obvious moral for international politics, since you may de- 
crease your chances of survival when you increase your firepower. 

Table 1 doesn’t show any cases where Quisling is the most likely to 
win. However, such cases are not impossible (for example when p = 0.2, 
q — 0.5, and r — 0.6). 


212 Selected Papers on Fun and Games 

3. But What If a Player Passes? 

The solution in (*) is very nice, but it is not correct. For example, see 
Martin Gardner’s discussion [1, Chapter 5] of the case p — 0.5, q — 0.8, 
r — 1.0; with those probabilities Petersen is better off shooting into the 
air when his turn comes! A simple calculation shows that his survival 
chances are improved if he misses Rasmussen, because the advantage of 
first shot in the eventual duel is of critical importance. 

The possibility of passing one’s turn leads to quite a different analy- 
sis of the triel. Consider the following scenario: Petersen passes, thereby 
improving Rasmussen’s chances as well as his own, and it is Quisling’s 
turn. Quisling, thinking furiously because his life is at stake, hits upon 
a brilliant idea: He also passes! Now it is Rasmussen’s turn, and he 
has two choices. Should he fire at Quisling, or should he pass? If he 
hits Quisling, Petersen might get him (because Petersen will not find it 
advantageous to pass when Quisling is dead). On the other hand, if Ras- 
mussen passes, we reach precisely the situation we had before: Petersen 
finds it advantageous to pass, and Quisling passes for the same reason as 
he did previously. This latter situation is obviously optimum, from Ras- 
mussen’s standpoint, since it gives him a survival probability of 1; firing 
at Quisling would make his chances strictly less than 1 (unless p — 0). 

Therefore, Rasmussen adopts his best strategy: He passes. It sud- 
denly becomes clear that Quisling also did the best possible thing by 
passing, because this also raised his own survival probability to 1. 

Indeed, our argument shows that the best strategy for all players, 
in any triel regardless of the probabilities p, q , and r, is to shoot wildly 
on every turn, as long as none of p, q, r are zero. We have proved, by 
ironclad logic, that pacifism is optimal. 

Of course the players shouldn’t have gotten into the fight in the first 
place. But even if they do, it’s better for them to handcuff themselves. 

Many people, including the author, are alarmed at the possibility 
that nations will turn over their warmaking decision policies to comput- 
ers; it is certainly horrifying to contemplate the prospect of machines, 
rather than humans, making our life-or-death decisions. Yet the situa- 
tion described above seems to be a counterexample: A computer would 
have been able to determine the optimum “everybody passes” strategy, 
but humans would probably have been blinded by their emotions and 
feelings of “honor” ! How else can we explain the fact that the true opti- 
mum solution to this problem has just been published for the first time, 
in the present note, although many people have been considering it for 
more than thirty years? 


The Triel: A New Solution 213 

4. Further Exploration 

The argument for triels does not, unfortunately, carry over to duels. 
Suppose we have two contestants, Petersen and Quisling, and Petersen 
passes. Now it’s Quisling’s turn, and he has two alternatives. If he 
passes, his survival probability is 1; but if he shoots and misses, his 
survival probability will still be 1, because Petersen (who is in precisely 
the same situation as before) will pass again. Therefore, Quisling can 
reason that he loses nothing by taking a shot at Petersen. And therefore 
Petersen finds that passing is not an optimum strategy; so both players 
will shoot it out. This gives survival probabilities less than 1 to them 
both, while they could obtain probability 1 if they both passed. It’s a 
paradoxical situation because neither can trust the other. 

Similarly if we have a “tetrel” with four players, there is no reason 
to pass. Each player might as well take aim (at any other random 
player, it. doesn t matter which), since after one is eliminated we reach 
the three-person situation where nobody will shoot to kill. 

It is only in the three-person case that we reach the uneasy truce, 
by impeccable quantitative reasoning. Perhaps that is why the word for 
“truce” isn’t “deuce” or something else. 

5. Another Problem 

Consider finally what happens if we add a new rule for the trielists: 
At most k “passes in a row are allowed, where A: is a given number. 
When k — 0 we have the situation analyzed in Section 2 above. When 
fc = 1, a player who passes will force the next player to shoot. When 
k — 2, a player who passes will give the next player the chance to 
force the third player to shoot. This new rule is, of course, completely 
unenforceable from a practical standpoint; but it does lead to some 
interesting problems in pure mathematics. 

There isn’t space here to give a complete analysis of this problem, 
but the solution can be briefly summarized. First we can prove that, for 
all fixed k < oo, Rasmussen’s best strategy never involves passing. This 
is intuitively clear, because both of the others will shoot at him if they 
shoot at anybody; and it can be proved rigorously as follows. Let R, be 
Rasmussen’s survival probability under the best strategy, when it is his 
turn after i consecutive passes have just been made, where 0 < i < k. 
His best strategy is either to shoot at Quisling (in which case Ri has 
a fixed value 5, independent of i), or it is to pass. In the latter case 
we either have R t — R i+3 (if both opponents also pass) or R t < Rj for 


214 Selected Papers on Fun and Games 

some j (if they don’t both pass). So, by passing he can never get more 
than S, which he obtains by shooting. 

Since Rasmussen never passes, it follows that each player confronts 
each turn in the same state, with respect to the number of consecutive 
passes that have just taken place, except possibly on their very first turn. 
Furthermore, only the cases k = 0, k = 1, and k = 2 can possibly be 
different; for k > 3 the best strategies will be the same as when k — 2. 

Let us now assume that Petersen shoots first, then Rasmussen, then 
Quisling. In this case the survival probabilities may be calculated as 
follows: Let a = f(q,p), b = f(p,r), c = f(p,q), where / is the two- 
person function defined above. Define the three quantities 

Poo = ( pa + prb + pfqc) /( 1 - pqr) ; 

Qoo = {qc + qpa)/( 1 -pqr); 

Roo = rb/( 1 - pqr). 

Here x stands for 1 — x. Now define three further quantities P 10 , Q io, 
Rio by setting q to 0 in the formulas for P 00 , Qoo, Roo, while leaving the 
values of a, b, c unchanged. (Thus, Q 10 = pa/ {l -pf), etc.) Define Pox, 
Qoi, Rox similarly by settings to 0, and define P u , Q u , R n similarly by 
setting both p and q to 0. The survival probabilities are now determined 
by the rules shown in Table 2. 


TABLE 2. Rules for the shooting order ( P,R,Q ) and limited passing 


If 

Petersen’s 
chances are 

Quisling ’s 
chances are 

Rasmussen’s 
chances are 

Qoo > Qio, Poo > Pol, Pro > Pn 

Poo 

pa + pfQoo 

pRoo 

Qio > Qoo, Poo > Poi, Pro > Pn 

Pio 

pa + pfQ io 

pRio 

Qoi > Qio, Pn > Poo, Pio > Pn 

Poi 

pa + pfQoi 

pRoi 

Qio > Qoi, Poi > Poo, Pio > Pn 

Pio 

pa + prQoi 

PRio 

Qoi > Qio, Pio < Pn 

Poi 

pa + pfQoi 

PRoi 

Qio > Qoi, Pio < Pn, k > 2 

Poi 

pa + pfQ oi 

PRoi 

Qio > Qoi, Pio < Pn, k = 1 

rb + fqc + fqPio 

rQio 

Rio 


One can show that Pro < Pn implies Poo < Poi, so some of the 
conditions in Table 2 can be slightly simplified. Furthermore, a some- 
what more complex argument shows that P 00 > P 0 i implies Qoo > Qio; 
hence the second case never actually occurs. Each of the other cases is 
possible, for some choices of p, q, and r. (Remember that these formu- 
las apply only when Petersen shoots first, then Rasmussen.) The other 
five starting configurations can be analyzed in a similar fashion, and 
fortunately they are simpler. 


The Triel: A New Solution 215 


A list of all the complicated formulas would not be very interesting; 
let us merely tabulate some typical values (Table 3), averaged over all 
six shooting orders as in the previous table for k — 0. 


Table 3. Examples of the probabilities for fc-limited passing 


p 

9 

r 

k 

= 1 


k>2 


P 

Q 

R 

P 

Q 

R 

0.2 

0.4 

0.6 

.327 

.227 

.446 

.327 

.227 

.446 

0.2 

0.4 

0.8 

.278 

.168 

.554 

.278 

.168 

.554 

0.2 

0.4 

1.0 

.239 

.164 

.597 

.239 

.164 

.597 

0.2 

0.6 

0.8 

.260 

.276 

.464 

.260 

.276 

.464 

0.2 

0.6 

1.0 

.228 

.212 

.560 

.228 

.212 

.560 

0.2 

0.8 

1.0 

.215 

.305 

.480 

.215 

.305 

.480 

0.4 

0.6 

0.8 

.446 

.197 

.357 

.483 

.185 

.332 

0.4 

0.6 

1.0 

.413 

.147 

.440 

.438 

.142 

.420 

0.4 

0.8 

1.0 

.422 

.218 

.360 

.422 

.218 

.360 

0.6 

0.8 

1.0 

.567 

.180 

.253 

.621 

.139 

.240 


As we might expect, the strategy of passing generally helps Petersen and 
Rasmussen at the expense of Quisling. 

None of the cases listed in Table 3 have the property that everyone’s 
optimal strategy is to shoot. However, there are situations (for example 
when p = 0.2, q = 0.3, and r = 0.8) where passing is never a good idea. 

One final note: Perhaps each player would rather die than live while 
the other two are still alive; or perhaps the triel is about a beautiful girl 
who will marry only the winner. In such a case the analysis in Section 3 
is inapplicable, and the rule considered here for k = 2 seems to give the 
appropriate formulas. Then, Quisling’s idea (to pass after Petersen has 
passed) is not so brilliant after all, since his survival probability drops 
to zero. 

It is also possible to argue that the analysis in Section 3 fails because 
sooner or later one of the participants will die of old age; then we are 
left with a duel! But this argument is problematical, since (for example) 
every mortal man has a survival probability of zero in the long run. 

This research was supported in part by Office of Naval Research contract 00014-67- 
A-01 12-0057 NR 044-402, and in part by Norges Almenvitenskapelige Forskningsrad. 


References 

[1] Martin Gardner, The Second Scientific American Book of Math- 
ematical Puzzles and Diversions (New York: Simon & Schuster, 


216 Selected Papers on Fun and Games 

1961). Republished with additions as Origami, Eleusis, and the 
Soma Cube: Martin Gardner’s Mathematical Diversions (Washing- 
ton, D.C.: Mathematical Association of America, 2008). 

[2] H. D. Larsen and Leo Moser, “A dart game,” solution E811, Amer- 
ican Mathematical Monthly 55 (1948), 640-641. 

[3] Hubert Phillips, “Triangular test,” in Question Time (London: J. 
M. Dent, 1937), 125, 261 [problem 223], 

Addendum 

My word ‘triel’ for a three-way duel has not picked up much support 
from other authors. Martin Shubik had coined the term ‘truel’ for the 
same notion [Game Theory and Related Approaches to Social Behavior 
(New York: Wiley, 1964), 43]; so had Richard A. Epstein, independently 
[The Theory of Gambling and Statistical Logic (New York: Academic 
Press, 1967), 343-347], Other authors, like David L. Silverman [ Your 
Move (New York: McGraw-Hill, 1971), 179-180, 214], have followed 
their lead. On the other hand John C. G. Boot [Mathematical Reasoning 
in Economics and Management Science (Englewood Cliffs, New Jersey: 
Prentice-Hall, 1967), 92-98] wrote about ‘trielling games’. He and I were 
evidently thinking of analogous instances such as ‘duet’ versus ‘trio’. 

Neither ‘truel’ nor ‘triel’ appears in the Oxford English Dictionary, 
vintage 2010, or in the Stanford GraphBase list of five-letter English 
words. Google’s index of the Web in 2003 cited ‘triel’ only 1481 times and 
‘truel’ only 1487; by contrast, the word ‘games’ appeared 105,373,578 
times in their index, and ‘duels’ had a count of 108,665. So I consider 
that the jury is still out. I hesitate to adopt ‘truel’ myself, because ‘triel’ 
sounds less cruel to my ears. 

I wasn’t the first person to realize that the all-pass strategy is best. 
Kenneth Kloper wrote to Martin Gardner on 3 September 1958, after 
seeing Martin’s article in Scientific American the previous month (a pre- 
cursor to [1]), in order to demonstrate what he called 

the correct and unique solution: Every morning, at sun-up, three 
proper gentlemen — a physicist, an engineer, and a bookkeeper — 
properly fire into the air; old age will claim the survivor. 

Kloper also cautioned, however, about the unfortunate possibility of a 
suicide by their second — a mathematician who couldn’t accept the fact 
that such a logical answer was “so unreasonable and yet so correct.” 

Similarly, after Gardner’s book [1] appeared, he received a letter 
from 1st Lieutenant James Eric Schonblom of the U.S. Army Munitions 
Command, dated 8 June 1963. Schonblom’s letter concluded by saying 


The Triel: A New Solution 217 

The analogy with international relations is complete as this “cold 
war situation continues, each firing into the air and eyeing the 
others warily. 

I prefer to believe that persons intelligent enough to realize 
that survival is rooted in pacifism cannot continue the farce for- 
ever. Sooner or later one of them will begin laughing, the seconds 
will declare that honor has been satisfied, and all three can go 
home to ponder why they ever considered duels and survival com- 
patible in the first place. 

(Gardner's correspondence files now reside in the Stanford University 
Archives; Martin gave me the opportunity to study them in 1994.) 

Thus Kloper, Schonblom, and I independently came to the same con- 
clusion. But is it really correct? Is our reasoning truly bulletproof? I’ve 
lectured about this topic to several math clubs, and I haven’t succeeded 
in convincing all the skeptics, probably because of a hidden assumption 
that I failed to state in my article and in my lectures. 

Namely, I should have elaborated on point (e) in the third paragraph 
of my article: Not only do I assume that p, q , and r remain constant, 

I also assume that the players’ strategies do not depend on any past 
history. The game that I studied has only 6 + 6 states, one for each 
order in which the surviving players will make sequential decisions. Thus 
an optimizing player will always make the same decision in the same 
situation. (In principle, I would however allow a player to flip a coin 
instead of adopting a “pure” strategy, as long as he uses the coin flips 
in the same way when in the same state.) 

Robert Axelrod wrote me a delightful letter in 1984, observing that 
my article was championing “passifism.” His version of my hidden as- 
sumption was the following: 

If a player makes a given choice he will always make that same 
choice in the same situation, and this fact is common knowledge. 
Everyone knows it and everyone knows that everyone else knows it. 

In particular, the first player commits himself to a future course of action 
by making a particular choice now, without knowing what the second 
player s choice will be, except that it will be optimum. And the second 
player’s choice must be optimum also if he had happened to be first: His 
strategy, which depends only on the game state, is essentially decided 
before the random selection of who shoots first and who shoots next. 

With this understanding, Axelrod proceeded to convince me that 
“passifism” is therefore optimum in the two-person duel as well. A 
player who passes is guaranteeing that his opponent has no reason to 


218 Selected Papers on Fun and Games 

shoot back, as far as the opponent’s survival is concerned. Conversely, 
a player who doesn’t pass will risk survival probability less than 1, in 
cases where he doesn’t go first. 

In a way, I like that. I’ve occasionally wished that the cowboys in 
old Western movies had meant “It’s a tie game” when they said “Draw”! 

But if the two-player case is resolved in that way, my analysis of the 
three-player case goes out the window, since I based it on the probability 
f(p, q) of winning a shootout. Suppose, for example, that Rasmussen is a 
sure shot, so that r = 1. Isn’t it better for him to wipe out one of his op- 
ponents and then to bask comfortably in the safety of the resulting duel? 
Well, no; for then he’ll be giving up his chance to prove to the others 
that he’s no threat. They’ll have to shoot at him when he isn’t first. 

Aha, we still conclude that pass-pass-pass is the best way for three 
competitors to proceed. 

Hmm. That argument points up a fallacy in my analysis of the 
four-player case: I had claimed that each of the four could shoot with 
impunity until reaching a three-player safety net, but I didn’t properly 
think through the risk of missing. The correct solution, under my as- 
sumptions, is actually for all players in any sequential n - way duel to 
shoot into the air (or even better, into the ground), regardless of n. 

Clearly I’m not competent to work on problems like this, and I’d 
better “pass” them on to other people who understand them better. 
(Should I, however, also trust a machine to find the solution?) 

Many variants are obviously possible. For instance, Epstein allowed 
the players to choose their probabilities p, q, and r arbitrarily, after the 
shooting sequence had been selected by lot; and in the all-pass case, he 
supposed that each winner had only 1/3 of a life! 

Three-way duels have added spice to dramatic productions such as 
A. P. Herbert’s Fat King Melon and Princess Caraway (London: Ox- 
ford University Press, 1927), and to movies such as Sergio Leone’s The 
Good, the Bad, and the Ugly = II Buono, il Bruto, il Cattivo (1966); 
Quentin Tarantino’s Reservoir Dogs (1992) and Pulp Fiction (1994); 
Gore Verbinski’s Pirates of the Caribbean: Dead Man’s Chest (2006). 

Further information can be found, for example, in “The truel,” 
by D. Marc Kilgour and Steven J. Brams, Mathematics Magazine 70 
(1997), 315-326. 


Chapter 25 


The Computer as Master Mind 

[Originally published in the Journal of Recreational Mathematics 9 
(1976), 1-6.] 

A deductive game called Master Mind, produced by Invicta Plastics, 
Ltd., enjoyed a wave of popularity during the 1975 Christmas season [2]. 
In this game one player (the “codemaker”) conceals a four-symbol code, 
and the other player (the “codebreaker” ) tries to identify all four symbols 
by trying appropriate test patterns. There are six symbols, represented 
by pegs of different colors, and repetitions are permitted; hence there 
are 6 4 = 1296 possible codewords. If the codemaker’s secret codeword 
is XiX 2 X 3 X 4 and if the codebreaker gives the test pattern yiy^yzVA, the 
codemaker rates that guess by announcing 

1) the number of “black hits,” namely the number of positions j such 
that Xj = yj ; 

2) the number of “white hits,” namely the number of positions j such 
that Xj / yj although Xj does equal y ^ for some k, where y k hasn’t 
been used in another hit. 

For example, let the symbols be denoted by 1, 2, 3, 4, 5, 6. If the 
codeword is 2532 and the test pattern is 3523, there are two white hits 
and one black hit. Rule (2) is somewhat difficult to state precisely and 
unambiguously, and the manufacturers have not succeeded in doing so on 
the directions they furnish with the game — although Games <fc Puzzles 
magazine [7, 8] has given them a rating of 8 points out of 8 for clarity 
of explanation! Perhaps the clearest way to state the rule exactly, when 
speaking to mathematicians or to computers, is this: Suppose symbol i 
occurs ni times in the codeword and n' times in the test pattern, for 
1 < « < 6. Then the total number of hits, both white and black, is 

min(n 1; n\) + min(n 2 , n 2 ) H + min(n 6 , n' 6 ). 

It follows that the total number of misses (non-hits) is 

max(n 1 — n(, 0) + max(n 2 — n 2 , 0) + ■ • ■ + max(n 6 — n' 6 , 0). 


219 


220 Selected Papers on Fun and Games 

Notice that it is impossible to have three black hits and one white hit. 
The codebreaker tries to get four black hits, after constructing a mini- 
mum number of test patterns. 

The purpose of this note is to prove that the codebreaker can always 
succeed in five moves or less. Thus, the code can always be known after 
at most four guesses have been made; and in fact it will often be known 
earlier. A complex strategy to achieve this result, worked out with the 
aid of a computer, appears below in Table 1, in highly condensed form. 
Readers who have played Master Mind will be able to see how a real 
expert operates by studying this strategy carefully. 

Here is how to read Table 1: Every situation we can arrive at during 
a game corresponds to a certain number of codewords, and we assume 
that the reader can figure out all of the possibilities that remain at any 
given time. If there are n possible codewords remaining, the situation is 
represented in Table 1 by the notation 

n, if n < 2; or 

n ( 2 / 1 2/2 2/32/4), if n > 2 and if the answer to test pattern 2 / 12/2 2/32/4 will 
uniquely characterize the codeword; or 

n ( 2 /i?/ 22 / 32 / 4 *), if n > 2 and if the situation after test pattern 2 / 1 2 / 2 2/3 2/4 
is not always unique but there will never be more than 
two possibilities; or 

n (2/l2/22/32/4: Q 04 , &03, a 02, <*01, a 00; <213, £*12, Qll , &10', 

a 22, «21, «20; a 31> q 30; «4o), 
if n > 2 and if the test pattern 2/12/22/32/4 answered by 
j black hits and k white hits leads to situation ajk- 
The test pattern doesn’t need to be specified when n — 2, since the best 
approach is to name either of the two remaining possibilities. 

For example, the beginning of Table 1 can be freely translated thus: 
There are 1296 possibilities to start with. Your first 
test pattern should be 1122. Now if the answer is “four 
white hits,” only one codeword is possible (you can fig- 
ure it out, it is 2211), so you should guess that code 
next and win. If the answer is “three white hits,” only 
16 possibilities remain, and your next codeword should 
be 1213. The response must indicate at least one black 
hit; and if it is “one black hit, two white hits,” say, there 
are four possibilities, which can be distinguished by the 
answer to test pattern 1415. 

A more typical play of the game using the strategy of Table 1 arises 
when the answer to the first test pattern 1122 is “one black hit.” Then 


The Computer as Master Mind 221 

the original 1296 possibilities have been reduced to 256, and we go to 
the ninth situation of the fifteen situations following ‘1122:’ in Table 1; 
this is the situation just before the second semicolon on the outer level. 
The second test pattern (see F ) is 1344; and let’s say the answer is “one 
white hit.” Then 44 possibilities remain, and our third guess is 3526. If 
the result this time is “one black hit, two white hits,” Table 1 says that 
seven possibilities survive, and that the test pattern 1462 will distin- 
guish them. For example, the reader might wish to deduce the unique 


codeword that should be guessed after the following sequence: 

test pattern 

hits 

1122 

B 

1344 

W 

3526 

BWW 

1462 

BW 


(The answer appears at the end of this article.) 

Incidentally, the fourth move 1462 in this example is really a bril- 
liant stroke, a crucial play if a win in five is to be guaranteed. None of the 
seven codewords that satisfy the first three patterns could be used suc- 
cessfully as the fourth test pattern; for example, if we had tried 4562, the 
response BB would have failed to distinguish 3662 from 5532. A code- 
word that cannot possibly win in four is necessary here to win in five. 

Table 1 was found by choosing at every stage a test pattern that 
minimizes the maximum number of remaining possibilities , over all con- 
ceivable responses by the codemaker. If this minimum can be achieved 
by a “valid” pattern (a pattern that makes “four black hits” possible), 
a valid one should be used. Subject to this condition, the first such test 
pattern in numeric order was selected. Fortunately this procedure turns 
out to guarantee a win in five moves. 

If the first test pattern is 1123 instead of 1122, the same approach 
nearly works. But there is one line of play that fails to win in five, 
starting with 

1123 WW [222 possibilities] 

2214 WW [ 36 possibilities] 

3341 

The 6 possibilities now remaining after “BB” and the 7 after “BBB” can- 
not all be distinguished by any fourth move. There probably is a way to 
improve this variation by changing the second pattern. However, when 
the first test pattern is 1234 it appears to be impossible to guarantee a 
win in five, especially after 1234 WW [312 possibilities]. 


TABLE 1. A minimax strategy for Master Mind 


222 Selected Papers on Fun and Games 


O 

co 

iO 

CM 

CQ 

co 

LO 

CM 

co 

05 


LO 

st* 


CO 

LO 


2^ 

CO 


•rH O 
t-H > ^ 

?b" 

LO ]“! 

T-i 1 

V co 


o 
o 
o 
o 
o 

00 CM 


. &H 
CO 
LO 


CM Et} 
tH 00 
co s 


h q 

<N g 

CM 

tH o 


CO 

05 

CM 


CO 

CM 


* 

^ CO 
LO LO 
tH CN 
L0 CN 


CN ^ ^ 
CO ^ ^ 

CO < 

o' CM TH 

CM~ O O 

C? ^ 

cn t-h cn 
CN ^ ^ 

CO T 1 T— I 

CoT ^ ^ 

~ tH to 
^ H CO 
.-co CN 
^ CO CN 

T — 1 CO CO 

CM ^ ^ 

- tH CO 
I tH LO 
.- LO CN 
O CO CN 

o' CO CO 
o" H CM 
O ^ 1 ,—H 

O o o 
LO o" o' 

ttH „ 

CN O O 
CO 0 ~ . 


CO 

CO ^ 
LO LO 
■tH st* 




r . N ✓ 


. - 

CO 


o 

O st* 


Fi 

LO 

st* 



^ o" 

1 — i . - o 

T—\ 

co 


* 

CO 

st* CT 

st* 

N ' 


LO 

CO ^ 

^ ^ CM 

T— 1 

St* 


tH 

CO LO 





CO 

t-i tH 

co" 0 - 

st* 

o 


co 

' LO 

^ co — 

— 

. — 



CO st* 

° o' 

o 

/- — V 


st<" 

— ' 

.-co 

. ^ 

CO 


T—i 

^ CO 

^ — s CO -IO 

X- — V 

CO 



CO 

st* ' LO 

st* 

st* 


/* V 

LO ^ 

1 St* 

LO 

co 


St* 

CN 

CO 


/- — N 

co 

CO LO 

st*^ 

co" 

co 

CN 

^ LO 


— 

i— i 

CN 

St* CO 

^ CO 

LO 






st* 

CN^ 

st^ 

CM LO 

cm" ^ ^ 

X- V 

CO 




- ^ st* 

CO 

LO 

co" 

O 


CM CO LO 

^ co 

co 


. - 

co c^ 

.. n LO 

T—l CO 



St* tH 

CO ^ 
co” CO 


LO CO 


Sf T— I 

CO LO 
^ LO 
CO st* 

?T“l 

co ^ 

CN 

LO co 

st* 

CO tH 


o 

CM 


CO co 

T— I L0 

s « 

CO o 

cm" t-h" 

o" ^ 

- LO 
O LO 

a s 

co 

CN CO 
CO ^ 

T“H 

LO 

- CO 

fir ^ 

co st* 


- LO 

co 

1— l co 

. — T — I 

co co 

st* 

£ ^ 

CO 

« 5 

° w 

CM ^ 

- co 

M 2 

CN O 

CO, St* 

• CO o' 

cm" ^ 

o 

« s 


n 


CN 


^ CN 

tH ,, — v 

CO CO 
co co 


st* 


sf* 


co 

CO ^ 
CO _r 


co co 

LO LO 

^ 00 
CN 

co ^ 

CO st* 
LO LO 

co 

CN 


CO 


CN^ co" 

cm" ^ 

.- LO 

o co 

- CO 
O CN 

o' si*" 


CO CO 
CO LO 
sf* st* 
CN CN 


w ° 

CO LO 
LO st* 
CN LO 

st*" zl 
•' CO 
CT' CM 


CO 


st* ^ 
co * 

LO LO 
^ CN 
t>- CO st* 

- o' M 


LO 

LO 

CO 


CO 


St* 

co 


* 

CO 

st* 

st* 

co 


o 

CM 

o" 


CM 


LO 
p£ LO 
LO 
St* 

St* 

a; 

- sr 
O st* 


- ^ 
CN ^ 

$ 

o g 


o 

CM 

o' 
cm" 
^o 

CO 
CO 
LO 

ZD C° 


O LO 
St* 

, . ° St* Sf* 

r co • - co 

^ St* ^ ^ *“• 

° i °;:— 

V ® 

CO ^ 

LO LO 

CO co 

^ LO 
CO XH 


CO ’ — 1 LO 
St* . „ stf* 

co o co 

St* - ^ 


* 3 * co <0 

CO LO H 
LO LO ^ 
st* st* Z, 

CO lo" co 
cm" r— r 

o ^ 
"co 

1- I 
St* 


co 

co 

LO 

St* 


CO ^ 
CO 

O LO 

- LO 

o ^ 
o ^ 

cm" ^ 

- co 

CM CO 

CO ^ 
LO 

CO CO 


' — ^ ZO 

CO „ 
LO ^ 
CO CO 
st* CO 

^ co 

LO ^ 
CM LO^ 

o' o" 

CO ^ 
St* Co 
T-i CO 

'zS' 

- LO 
CO 
LO LO 
CO st* 
LO ' 
st* CO 

"5 s 

T— I CO 

• • co 

st* st* 
LO " 
st* co 
CO _r 


CO CO sf 

- LO 

^ co ^ 

- co 10 

O CD 
. - st* LO 

fo 

st* St* CO 
st* CO 

St* CO CM 

^co- 
co ^ o 

- CO _ 

co o" ^ 

st* _ st* 
s O st* 

co ^ 

co" 2; St* 

g LO £ 
co co st* 

CO ^ st* 

LO - — ^ LO 

CO ^ V 

o" ^ 

. - O LO 
T— i ..CO 

- co co 

I— I st* LO 

- ^ " — " 

1—1 co co 


CO 



co 






CO 


st* 


o 



CM 


T—i 

o 

t-H 

CN 

t-H 

O 

LO 

t-H 

O 

t-H 

* 

^ o 

o 

st* 

t-H 

o 


o 

— 






St* 




LO 

o • • 





^ ^ 


CM 

LO 

LO 


CO 

LO 

CN 

<b* 

LO 

^ — v 

CO 

CM st* 

cb 

^ s. 

cb 

cb 

* 

cb 

— 

N-H 

1— 1 

— 

tH 

tH 

CO 

t-H 

t-H 

st* 

CO 

- CO 

st* 

CO 

co 

LO 

LO 

co 

o 

CN 

St* 

o 

LO 

LO 


LO 

CO 

CO 

tH 

CM LO 

CO 

LO 

CO 

CO 

co 

co 

^t* 

LO 

CN 


CO 

LO 

r— 1 

st^ 

co 

St* 

s ✓ 


co 

st* 

co 

co 

st* 

co 



st* 



CM 



CN 

C5 

LO n — ✓ 


co 



co 


St* 

St* 

00 

st* 

st* 

CO 


CM 

st* 


st* CM 

CO 


CO 

oo" 


cT 

CO 

CN 

r— 1 

T—l 

CO 

CN 

St* 

t-H 

cm" 

st* 

CO 

CO 

o" 

CO st* 
CO 

rH 

st*" 

St* 

T-H 

LO 

CM 


cq 


o 


(1213: 1,4(1145), 3(1415), 0,0; 0,6(1114*), 7(2412*), 0; 2, 4(1145), 4(1145*); 0,4(1114*); l) 

(1134: 0,4(1312), 24(3521: 1,2, 4(4612), 0,0; 0, 3(3312), 3(2423), 0; 2,2,3(4621); 0,3(3321); 1), 
38(2352: 2, 4(3226), 4(5621), 1,0; 1, 5(2223), 7(6242), 1; 2, 4(2323), 4(2462); 0,2; 1), 
20(2525:1,2,1,0,0; 0, 3(2252), 3(2262), 0; 2,2,2; 0,3(2225); 1); 


The Computer as Master Mind 223 


o 

CNp 

o' 


Zl ^ CN 

T-H tH 

o~ ^ 

•rH r_l 

csf ^ ^ 

~ LO * 

® n S 

2 o-2 


■rH •rH ^ 
W LO H 

co lo cn 
Zls ,|H ‘ rH 
CO CO 

S 2 N 

s « ° 

CO o' ® 
^ ^ o' 

rH LO * 
LO ^ CN 
^ CN • - 

CD -rH 

" «' V ✓ ^ 

CO CN 

- r CN 

rH CN 

© ^ 
„ <D 
° 

CN 

tH - CN 
(O CN 11) 

5 

CN CM 




t-H 


Lf? 




i-H 

/- — V 

t-H 

rH 

' — 

. r. 


^ — s 

r. 


o 

CN 

. ^ 


^ — -V 


LO 


CN 

co of 

LO 

^ CO 


O CN 


CD 

CO 


CO 

o' 


CD 

CO 


CO "l 

LO ^ 
-rH CN 
CO LO 
^ LO 
^ CO 

CN LO 


co CO 
CN CN 

^ -rH 

CO ^ 
co" CO 


CO 

CN ^ 

^ CN 
CO LO ^ 

ST 3 " 

<o - — ■ , „ 

H CN ^ 
LO <£> ’ H 

co" 21 ^ 
o' o 

^ "t»T No" 

^ CN -H 
CO (O LO 
CN LO H 

“ n m 
co o 

CN r S 


CO 
CO 

ol O- 

S ° 

co t— 7 

CN CO 
CO 

^ co 

.—7 co 

^2 (N 

CO CO 7-7 

^ - "T 

« g I 

« 5 S' 

® w C? 

^ CM 
_T CD 

-i* J5 w, 

co 2 

CO ^ ^ 

^ . CN 

C^ o CD 
e4 . . co 

• - CO w' 

o CO ^ 
CN 2 1-T 


- CO 
" N CN 

o' 

o' 

^ -*() 

T— 1 

rH C_> 

. „ 


LO 

r 

LO 

o 

o 

LO 

CN 

rH ^ 



rH 


^ O 

CN 

LO 

CO 

CN 



co 



CO ^ 

^ — s 

•rH 

CO 

O 

^ LO 


CO 


• c- 

’ — 1 ^ 

CN 


/- V 

o 

• • -rH 

LO 

1— 1 

CN 


LO CN 

CN 


LO 

rH 

rH ' — ^ 



CO 


co co 


/- — V 


t-H 

rH - 


LO 



CN 

o 

CO 


o 



co 

rs 

r- 

CO CN 

i-H 

tH 

t-H 

o 






^ co 

cb 


cb 

ib 


o 

o 

o' 


CD 

CO 


CO 

co 


CO 

LO 

co 


co 

LO 


o' 

o' 

CN 

CO 

CO 

ftp 

CN 

o" 

o' 

LO 

tH 


^ ^ 

CT ^ ^ 

• ^ LO co 
o co co 
- CO LO 

tH tH 

o' ^ ^ 

CO CO CN 
CO LO 
^ ^ CO * 
rH rH LO LO 

fO N CO ^ 
H t-H O 

o 


CO 

CN 


LO 

^ LO CN 
CO -rH rH 

' CN CN 
^ CO CN 


• CN CN 
O LO LO 
V CO LO 

n — ✓ ' 

N 1 ^ CO 
CO ^ H 


LO 

^ . . . . 
-rH ^ LO 
co CN CN 
w LO CO 
’ — 1 co 

CN ' — ' — " 
- CN Tt< 
CN ^ CO 


co ^ 

t-H * 

. LO 

CO 
CO tH 

rH C5 

CO o' 


LO 


CO 

o' 

LO 

i — I 


LO 

CN 


T}H 

CN 


LO 


LO 

rH 

CN 

LO 

o' 

o' 

o' 


CO 


LO 


CN 

ffP 


co 

CN 

CN 


II II II 

q bq q 


II II II 


(1234: 2, 16(1325: 1,3(4152), 3(4162), 0,0; 1, 3(3126), 2, 0; 1,1,1; 0,0; 0), 

20(1325: 0,3(5162), 1,0,0; 0, 2, 4(4522), 4(4622); 0, 3(5125), 3(2116); 0,0; 0), 
6(2515), 0; 4(1323), 21(1352: 0, 1, 2, 0, 0; 2, 4(1623), 2, 0; 1, 3(1323), 3(1462); 0,2; 1), 
16(2156*), 12(1315*); 2, 6(3526), 8(1536*); 0,1; 0) 

(1223:0,0,0,0,0; 1, 5(1145*), 4(1114*), 0; 1, 3(1415), 4(1114*); 0,2; 0) 


224 Selected Papers on Fun and Games 

The strategy in Table 1 isn’t optimal from the “expected number of 
moves” standpoint, but it is probably very close. One line that can be 
improved occurs in D, after 

1122 BWW 
1213 BB 

when there are four possible codewords {2212,4212,5212,6212}. The 
pattern 4222* distinguishes them more quickly than the arithmetically 
smallest decent pattern 1145* does. 

It is not clear what the optimum strategy would be if we use the 
interesting new scoring rules proposed by G. W. Gill in [4]. 

Historical Note 

A game very similar to Master Mind, called “Bulls and Cows,” has 
been popular in England for many years. The difference is that all 
digits of the code in Bulls and Cows must be distinct; but any digits 0 
through 9 are allowed. This version of the game has become a popular 
computer demonstration, after Frank H. King introduced a program for 
it in August 1968 at Cambridge University [3,5,6]. 

References 

[1] “Games gift guide,” Games & Puzzles 20 (December 1973), 16-17. 
[Attributes the invention of Master Mind to M. Meyerowitz.] 

[2] “And now, Master Mind,” Time 106,22 (1 December 1975), 73. 

[3] Ho [Aleph-Null], “Computer recreations,” Software — Practice Sz 
Experience 1 (1971), 201-204. 

[4] G. W. Gill, letter to the editor, Games &: Puzzles 26 (July 1974), 

22 . 

[5] Jerrold M. Grochow, “MOO in Multics,” Software — Practice & 
Experience 2 (1972), 303-304. 

[6] Frank H. King, “The game of MOO,” University of Cambridge, 
Computer Laboratory (February 1976), 5 pages. 

[7] Richard Sharp, review of Master Mind, Games Sz Puzzles 12 (April 
1973), 21. 

[8] David Wells, “Master Mind: The story of an experiment,” Games 
Sz Puzzles 23 (March-April 1974), cover, 10-11. 

Answer to Secret Codeword 

16 x 227. 


The Computer as Master Mind 225 

Addendum 

Of course I wouldn’t stick precisely to the strategy of Table 1 if I were the 
codebreaker in a real game. I’d randomize it, by choosing a random per- 
mutation P 1 P 2 P 3 P 4 of the positions {1, 2, 3, 4} and a random permutation 
919293949596 °f the colors {1, 2, 3, 4, 5, 6}. Then when Table 1 mentions 
a pattern xix 2 x 3 x A , I would actually use the pattern q Xpi q Xpp q Xp 3 q Xp4 - 

The question I raised about minimizing the “expected number of 
moves” can be rephrased to ask for a nonrandomized strategy that makes 
the fewest total guesses, summed over all 1296 codewords. The strategy 
in Table 1 yields 5801 guesses; the improvement that I mentioned for 
part D yields 5800, for an average of 5800/1296 sa 4.4753. Robert W. 
Irving [“Towards an optimum Mastermind strategy,” Journal of Recre- 
ational Mathematics 11 (1978), 81-87] improved this by finding a strat- 
egy that needs only 5662 total guesses, or an average of « 4.3688. The 
codebreaker’s first guess in his strategy is 1123, not 1122. He needed six 
guesses to deduce one of the secret codewords, but he could modify his 
scheme for a maximum of five by increasing the total from 5662 to 5664. 

A still better guessing procedure, with total 5656, was found by 
E. Neuwirth [“Some strategies for Mastermind,” Zeitschrift fur Opera- 
tions Research 26 (1982), B257-B278], increasing to 5658 if limited to 
five guesses per codeword. 

Finally, the best possible total — 5625 guesses — was published by 
Kenji Koyama and Tony W. Lai [“An optimal Mastermind strategy,” 
Journal of Recreational Mathematics 25 (1993), 251-256], who did an 
exhaustive depth-first computer search. The average with their method 
is therefore 5625/1296 sa 4.3403. They also showed how to obtain a total 
of 5626 guesses without needing more than five per codeword. 

Merrill M. Flood [“Mastermind strategy,” Journal of Recreational 
Mathematics 18 (1986), 194-202] considered the more general problem 
in which both codemaker and codebreaker try to optimize their policies. 
A codemaker who knows the codebreaker’s strategy can do better by fa- 
voring some codewords over others. For example, the scheme of Koyama 
and Lai has the following distribution of guesses per game: 


xxxx 

0 

0 

1 

5 

0 

0 

23/6 p 

a 3.833 

xxxy 

0 

0 

2 

72 

46 

0 

524/120 p 

a 4.367 

xxyy 

0 

0 

2 

55 

33 

0 

391/90 p 

a 4.344 

xxyz 

1 

8 

49 

357 

304 

1 

3118/720 s 

a 4.331 

wxyz 

0 

0 

32 

167 

161 

0 

1569/360 s 

a 4.358 


(The entry in row 4 and column 3 of this chart means that 49 of 
the 720 codewords of the permuted form xxyz are unmasked on the 


226 Selected Papers on Fun and Games 

codebreaker’s third guess, etc.) If the codemaker always chooses code- 
words of the permuted form xxxy, such as say 2522, the codebreaker 
ends up making about 4.367 guesses per game; that’s noticeably worse 
than the 4.340 guesses needed to crack a completely random codeword. 

The strategy of Koyama and Lai can, however, be made more bal- 
anced by making simple changes to the guesses in a few cases where 
only two possibilities remain. For example, there’s a situation where 
they guess 1111 when the only other candidate is 1166; by guessing 
1166 first, they could increase the average cost for patterns of type 
xxxx to 24/6, but decrease the cost for xxyy to 390/90. By making a 
dozen carefully chosen swaps of this kind, their scheme can be modified 
so that it has the following distribution: 


XXXX 

0 0 

1 

4 

1 0 

24/6 = 

4.000 

xxxy 

0 0 

2 

75 

43 0 

521/120 Pa 

4.342 

xxyy 

0 0 

2 

56 

32 0 

390/90 sa 

4.333 

xxyz 

1 8 

49 

348 

313 1 

3127/720 « 

4.343 

wxyz 

0 0 

32 

173 

155 0 

1563/360 « 

4.342 


Against this strategy, the codemaker can force only 4.343 guesses per 
game, on the average. 

In 1985 I received an unpublished description of a still better 
method, entitled “An optimal Mastermind strategy,” from Tom Nestor, 
a mathematics graduate student at Oklahoma State University. His 
procedure achieves the minimal total of 5625 with a distribution that is 
almost perfectly balanced: 


XXXX 

0 

0 

1 

3 

2 

0 

25/6 p 

a 4.167 

xxxy 

0 

0 

2 

75 

43 

0 

521/120 p 

a 4.342 

xxyy 

0 

0 

2 

56 

32 

0 

390/90 p 

a 4.333 

xxyz 

1 

8 

50 

347 

313 

1 

3126/720 s 

a 4.342 

wxyz 

0 

0 

28 

181 

151 

0 

1563/360 p 

a 4.342 


With this scheme we need at most 4.342 guesses per game, regardless of 
what the codemaker tries to do; that’s very near the theoretical mini- 
mum of 5625/1296 « 4.340. 

Suppose the codebreaker must pay $1.20 for every guess, but re- 
ceives $5.21 whenever discovering a codeword. With the Koyama-Lai 
methods the codebreaker might lose money; but with Nestor’s strategy, 
the codebreaker can break even, in the long run, against all comers. 

Furthermore, the codebreaker can actually make a profit in this ver- 
sion of the game by being more clever. If we make one or two appropriate 


The Computer as Master Mind 227 

changes to Nestor’s original scheme, by swapping guesses in well-chosen 
cases where just two possibilities remain, we can obtain pure strategies 
Ni, N 2 , IV 3 for which respectively 

(520/120, 391/90, 3126/720, 1563/360) 

(521/120, 391/90, 3125/720, 1563/360) 

(521/120, 391/90, 3126/720, 1562/360) 

guesses will resolve the non-xxxx patterns, while the xxxx patterns 
remain easy. By using (No, Ni , N 2 , A r 3 ) with the respective probabilities 
(13, 3, 18, 9) / 43, where N 0 is Nestor’s strategy, we could then win at 
least $1/1720 per game, on average, against any codewords. In other 
words, the expected number of guesses per game would then be at most 
521/120 - 1/1720 = 560/129 4.341. 

Conversely, a codemaker who chooses random xxxy, xxyy , xxyz , or 
wxyz with the respective probabilities (4, 3, 24, 12) / 43 can ensure that 
such a mixed strategy will force the codebreaker to make at least 560/129 
guesses per game, on average. This codemaking strategy is equivalent 
to choosing randomly among the 1290 non-xxxx codes. 

Tom Nestor, who has continued to develop sophisticated algorithms 
for studying Master Mind strategies, wrote to me again in 2010, stating 
that his programs yield a proof that 5600/1290 is the minimum aver- 
age number of guesses per game if we don’t allow the codemaker to 
choose xxxx — although xxxx patterns might still be guessed by the 
codebreaker if desired. It follows that the mixed strategy that we have 
discussed for (Nq, Ni, N 2 , Nz) is in fact optimum. 

In other words, Merrill Flood’s problem has now been resolved, and 
560/129 is the true value of the guesses-per-game criterion when both 
codemaker and codebreaker play optimally. 

The same result was, in fact, announced by Michael Wiener, in a 
posting to the sci.net newsgroup of Usenet on 29 November 1995, 
“from a program that ran for months.” Wiener had done this unpub- 
lished computation during the late 1980s. 

Nestor points out, however, that none of the strategies we’ve dis- 
cussed so far is really the best way to play Master Mind! The normal 
rules don’t ask us to minimize the expected number of guesses; they ask 
us rather to make fewer guesses, when we are codebreaker, than the op- 
ponent does when he or she is codebreaker. And that is quite a different 
problem. 

For example, let’s consider a symmetrical form of the game in which 
Alice and Bob each play against a computer. The computer chooses 


228 Selected Papers on Fun and Games 

codewords for each of them, in such a way that all of the 1296 2 pairs of 
codewords are equally likely. Alice discovers her codeword after making 
exactly a guesses, and Bob discovers his after making b. Alice doesn’t 
know anything about b while she’s playing, and Bob doesn’t know any- 
thing about a. Then we stipulate that Alice wins if a < b, Bob wins if 
a > b, and the game is tied if a = b. 

Nestor proved his point by sending me a strategy M, which has the 
profile (1, 8, 80, 679, 511, 17) compared to the profile (1, 8, 83, 662, 541, 1) 
of N = Nq. There are, for instance, 17 cases for which M needs 6 
guesses, while N has only one such bad case. The expected cost of M is 
proportional to (1, 8, 80, 679, 511, 17) • (1, 2, 3, 4, 5, 6) = 5630, compared 
to the optimum (1, 8, 83, 662, 541, 1) • (1, 2, 3, 4, 5, 6) = 5625 of N. But if 
Alice plays M against Bob’s N, she wins with probability 

(1 ■ (8 + 83 + 662 + 541 + 1) +8 -(83 + 662 + 541 + 1) + •■■ + 511 • l) /1296 2 , 

about 28.37%, while he wins with probability 

(l - (8 + 80+679 + 511 + 17) + 8- (80+679 + 51 1 + 17) + - - - + 541 ■ 17) /1296 2 , 

about 28.01%; otherwise the game is tied, with probability 

(1 • 1 + 8 • 8 + 80 • 83 + • ■ • + 17 • 1 )/ 1296 2 « 43.62%. 

Alice racks up her advantage over Bob’s supposedly “optimum” play by 
being rather good at guessing codes in four steps or less. 

A similar phenomenon was found for the game Bulls and Cows by 
Tetsuro Tanaka [“An optimal MOO strategy,” Proceedings of a Game 
Programming Workshop (1996), 202-209, in Japanese]. He showed that 
the minimum expected cost for that game is 26274/5040, obtained with 
a guessing scheme T whose profile is (1,7,63,697,2424,1774,74); yet 
he also found a scheme T' with profile (1, 4, 47, 688, 2531, 1628, 141) and 
expected cost 26312, which wins against T more often than it loses. [See 
also John Francis, “Strategies for playing MOO, or ‘Bulls and Cows’” 
(preprint, 2010).] 

Nestor went on to prove that his strategy M will beat any strat- 
egy whose profile differs from (1, 8, 80, 679, 511, 17), in this symmetrical 
version of the game. 

On the other hand, Master Mind is usually played sequentially: Al- 
ice, say, is the first to break a code; then Bob will know the value of a 
when it is his turn to be the breaker. This gives him a significant ad- 
vantage, because he can choose different optimum strategies depending 


The Computer as Master Mind 229 

on how lucky or unlucky Alice was. If, for example, a = 6, Bob can 
guarantee victory by using Table 1. 

Let p a be the probability that Bob wins minus the probability that 
Bob loses, if he plays optimally for a given value of a. (His optim um 
strategy depends only on a, not on Alice’s method of guessing.) Then 
fie — 1; and Pi = 1/1296 — 1, because a = 1 forces Bob to lose except 
when he happens to guess the code on his first try. Nestor has developed 
an efficient algorithm to determine optimum strategies for the other cases 
a = 2, 3, 4, and 5; then, knowing the values (/3i, P 2 , P 3 , Pa, P 5 , P&), his 
algorithm is also able to determine Alice’s optimum strategy. Of course 
I hope he will publish these exciting new results soon. 

I’ve placed an expanded version of Table 1 on the Internet, as 
file 'http://www-cs-faculty.stanford.edu/~knuth/mm.txt’. It is a 
11533- byte long parenthesized formula that begins with 

1296(1122:1(2211) ,16(1213:0,0,0,0,0:1(2311) , 
and ends with 

2(1125,1126) ; 0,1 (1124) ;0) ; 0 , 2(1123 , 1222) ; 0) ; 1 (1122) ) 

and has cases like 

4(5624 , 5524 , 6362 , 6524) , 5(6624 , 1555 , 1565 , 1655 , 1665) 

in the middle. The conventions of Table 1 are simplified so that ‘n’ 
appears by itself only if n = 0; ‘n(gi, 52 , ■ . . , g n )' appears whenever 
the remaining codewords are { 91 , 92 , • • • , 9n} and you’ll know the truth 
after guessing gi. (The former notation n(j/i 2 / 22 / 32 / 4 *) is not used.) My 
website also contains similar files mm-n0.txt, mm-nl.txt, mm-n2.txt, 
mm-n3.txt, and mm-m.txt for Nestor’s optimum strategies No, N±, N 2 , 
IV3, and M . 

Incidentally, the question of optimum play in Gill’s sense (see [4]) 
remains open. Gill proposed minimizing the sum G + B + 2W + 3N, 
where there are G guesses, B black hits, W white hits, and N non-hits. 
Since N + W + B — 4 G, his goal is to minimize 13G — 2B — W. 



Chapter 26 


Move It Or Lose It 


[Originally published in Variant Chess 8 (2009), 96, based on a letter 
written to Martin Gardner on 9 January 2002.] 

Dear Martin, 

. . . During Christmas vacation I investigated a variant of chess that you 
might enjoy trying out with new friends that you happen to meet in a 
retirement community. I haven’t got a great name for it as yet; my son 
and I tentatively call it “15-Out” a.k.a. “Move It Or Lose It.” The idea 
is to encourage relatively quick games by requiring every piece to move 
at least once in every 15 turns. 

You play with ordinary chess pieces, but each player also has 15 
cards that fit under the pieces, each card being the size of a square on 
the board. The cards of each player are numbered from 1 to 15. One 
card is placed under every piece except the king; the numbers are visible 
to both players. 

Our initial setup was 



and it worked fine, but lots of other starting positions are plausible. 


231 


232 Selected Papers on Fun and Games 

All the rules of ordinary chess apply, and there’s also a new rule that 
sometimes removes pieces or pawns from the board: Each move has a 
serial number k that runs through the cycle 1, 2, 3, ... , 14, 15, 1, 2, 3, 

. . . , 14, 15, 1, etc. If you’ve moved anything besides a king on move fc, 
you put card k under that piece. Also, if card k was under a piece that 
you didn’t move, that piece is taken off the board. 

A few slightly subtle points arise: (1) When you castle, the rook is 
the piece that gets card k. (2) When a piece is removed because you 
didn’t move it at its “doomstime,” this might result in discovered check 
on your opponent. (3) A player is not allowed to move in such a way 
that losing a piece/pawn leaves his king in check; therefore there’s a new 
kind of stalemate. 

For example, here are the first moves in the first game that I played 
with my son John (who had the white pieces): 

1 e2-e4 

(The pawn remains above card 1.) 

1 ... e7-e5 

(Likewise.) 

2 Bfl-b5 

(He loses his d-pawn. The bishop becomes #2 and card #14 is tem- 
porarily retired until move 14.) 

2 ... c7-c6 

(I lose my d-pawn; card #4 temporarily leaves the board.) 

3 Qdlxd8+ 

(And he loses his f-pawn.) 

3 ... Ke8xd8 

(And I lose mine too. Card #3 goes off the board, since K gets no card.) 

4 Bcl-g5+ 

(Meanwhile he also loses his c-pawn.) 

4 ... Bf 8-e7 

(Card #4 comes back into play; card #14 is temporarily off; see Fig. 1 .) 

And so on. (My son was evidently in an aggressive, sacrificial mood.) 
(He won.) 

After a while the pieces dwindle and the new rules have less and 
less effect; players might reach a point where the cards are a nuisance 
because the pieces move frequently anyway. It helps to keep a record of 
the game, so that cards can be dispensed with in such cases. But games 
go fast, and there’s an interesting mix of new strategy versus old. 


Move It Or Lose It 


233 



Figure 1. The position after Black’s fourth move. 

Addendum: Comments by Editor John Beasley 

The game does indeed go fast, indeed it is so sharp that I fear opening 
play might soon become stereotyped. However, if this proves to be 
a problem, other starting arrays could be tried for the cards, or the 
players could even be invited to place them on the board one at a time 
as a preliminary phase. 

In the meantime, I tried substituting the beginner’s move 

3 Qdl-h5 

in the game above. This looks much stronger than in ordinary chess, 
because the imminent disappearance of Black’s f-pawn restricts him to 
a king move or . . . g6. Let’s try the latter: 

3 • • • g7-g6 . 

White naturally continues 

4 Qh5xe5+ , 
but after 

4 ... Qd8-e7 

5 Qe5xh8 

his own g-pawn has gone and 

5 ... Qe7xe4+ 

forks his own rook in return. Try 

6 Bb5-e2 

at least rescuing the bishop; then 

6 ... Qe4xhl 


234 Selected Papers on Fun and Games 
gives (I think) 



I think White must now rescue his queen by 

7 Qh8-e5+ 

or perhaps 7 Qd4. If he defends his knight by 7 Be3, his h-pawn will go, 
Black’s reply 7 . . . Bb4+ will give check and remove his own h-pawn, 
and White’s queen is dead. 

Strictly for fun, of course, but well worth trying. 



Chapter 27 


Adventure 


[The following unpublished example of “literate programming for fun” 
was originally placed online on 12 September 1998 and subsequently 
amended based on responses from readers. An electronic source file for 
this program is downloadable from the Internet site 

http : // www-cs- faculty . Stanford . edu/~knuth/programs . html 

under the name ‘ADVENT’.] 

1. Introduction 

The ur-game for computers — Adventure — was originally written by 
Will Crowther in 1975 or 1976 and significantly extended by Don Woods 
in 1977. I have taken Woods’s original FORTRAN program for Adven- 
ture Version 1.0 and recast it in the CWEB idiom. 

I remember being fascinated by this game when John McCarthy 
showed it to me in 1977. I started with no clues about the purpose of 
play or what I should do; just the computer’s comment that I was at 
the end of a forest road facing a small brick building. Little by little, 
the game revealed its secrets, just as its designers had cleverly plotted. 
What a thrill it was when I first got past the green snake! Clearly 
the game was potentially addictive, so I forced myself to stop playing 
reasoning that it was great fun, sure, but that traditional computer 
science research is great fun too, possibly even more so. 

Now here I am, 21 years later, returning to the great Adventure 
after having indeed had many exciting adventures in Computer Science. 
I believe people who have played this game will be able to extend their 
fun by reading its once-secret program. Of course I urge everybody to 
play the game first, at least ten times, before reading on. But you cannot 
fully appreciate the astonishing brilliance of its design until you have seen 
all of the surprises that have been built in. 

I believe this program is entirely faithful to the behavior of Ad- 
venture Version 1.0, except that I have slightly edited the computer 


235 


236 Selected Papers on Fun and Games 

messages (in most cases so that they use both lowercase and uppercase 
letters). I have also omitted Woods’s elaborate machinery for closing 
the cave during the hours of prime-time computing; I believe John Mc- 
Carthy insisted on this, when he saw the productivity of his AI Lab 
falling off dramatically — although it is rumored that he had a special 
version of the program that allowed him to play whenever he wanted. 
And I have not adopted the encryption scheme by which Woods made 
it difficult for users to find any important clues in the binary program 
file or core image; such modifications would best be done by making a 
special version of CTANGLE. All of the spelunking constraints and inter- 
active behavior have been retained, although the structure of this CWEB 
program is naturally quite different from the FORTRAN version that I 
began with. 

Many of the phrases in the following documentation have been lifted 
directly from comments in the FORTRAN code. Please regard me as 
merely a translator of the program, not as an author. I thank Don 
Woods for helping me check the validity of this translation. 

By the way, if you don’t like goto statements, don’t read this. (And 
don’t read any other programs that simulate multistate systems.) 

2. To run the program with, say, a UNIX shell, just type ‘advent’ and 
follow instructions. (Many UNIX systems come with an almost identical 
program called ‘adventure’ already built in; you might want to try it 
too, for comparison.) 

^include <stdio.h> /* basic input/output routines: fgets, printf */ 
^include <ctype.h> /* isspace, tolower, and toupper routines */ 
^include <string.h> /* strncmp and strcpy to deal with strings */ 
^include <time.h> /* current time, used as random number seed */ 
^include <stdlib.h> /* exit */ 

{ Macros for subroutine prototypes 3 } 
typedef enum { 
false , true 
} boolean; 

( Type definitions 5 ) 

( Global variables 7 ) 

( Subroutines 6 ) 

main ( ) 

{ 

register int j, k\ 
register char *p; 

(Additional local registers 22); 


INTRODUCTION 


Adventure 


237 


( Initialize all tables 200 ) ; 

(Simulate an adventure, going to quit when finished 75}; 

(Deal with death and resurrection 188); 
quit-. (Print the score and say adieu 198); 
exit( 0); 

} 

3. The subroutines of this program are declared first with a prototype, 
as in ANSI C, then with an old-style C function definition. The following 
preprocessor commands make this strategy work correctly with both 
new-style and old-style compilers. 

( Macros for subroutine prototypes 3 ) = 

#ifdef __STDC__ 

#define ARGS(fot) list 
#else 

#define ARGS(fof) () 

#endif 

This code is used in section 2. 


STDC , Standard C. 

exit: void ( ), <stdlib.h>. 
fgets : char *(), <stdio.h>. 
isspace: int ( ), <ctype . h>. 
printf: int (), <stdio.h>. 


strcpy: char *(), <string.h>. 
stmcmp : int (), <string.h>. 
time: time.t (), <time.h>. 
tolower: int (), <ctype.h>. 
toupper: int (), <ctype.h>. 


238 Selected Papers on Fun and Games 

4. The vocabulary. Throughout the remainder of this documenta- 
tion, “you” are the user and “we” are the game author and the computer. 
We don’t tell you what words to use, except indirectly; but we try to 
understand enough words of English so that you can play the game with- 
out undue frustration. The first part of the program specifies what we 
know about your language — about 300 words. 

5. When you type a word, we first convert uppercase letters to lower- 
case; then we chop off all but the first five characters, if the word was 
longer than that, and we look for your (possibly truncated) word in 
a small hash table. Each hash table entry contains a string of length 
5 or less, and two additional bytes for the word’s type and meaning. Four 
types of words are distinguished: motion-type, object-type, action-type, 
and message-type. 

( Type definitions 5 ) = 
typedef enum { 

no-type , motion-type , object-type , action-type , message-type 

} wordtype; 
typedef struct { 

char text[ 6]; /* string of length at most 5 */ 

char word-type- /* a wordtype */ 
char meaning; 

} hash-entry; 

See also sections 9, 11, 13, 18, and 19. 

This code is used in section 2. 

6. Here is the subroutine that puts words into our vocabulary, when 
the program is getting ready to run. 

#define hash-prime 1009 /* the size of the hash table */ 

( Subroutines 6 ) = 

void new-word ARGS((char *,int)); 

void new-word (w,m) 

char *w; /* a string of length 5 or less */ 

int m; /* its meaning */ 

{ 

register int h, k ; 
register char *p; 

for (h = 0,p = w; *p; p++) h = *p + h + h; 
h %= hash-prime; 
while (hash-table[h\. word-type) { 
h++; 

if ( h = hash-prime ) h = 0; 

} 


THE VOCABULARY 


Adventure 239 


strcpy (hash-table [h] .text , w ) ; 
hash-table [h], word-type = current-type ; 
hash-table [h]. meaning = m; 

} 

See also sections 8, 64, 65, 66, 71, 72, 154, 160, 194, and 197. 

This code is used in section 2. 

7. ( Global variables 7 } = 

hash_entry hash-table [hash-prime]\ /* the table of words we know */ 
wordtype current-type ; /* the kind of word we are dealing with */ 

See also sections 15, 17, 20, 21, 63, 73, 74, 77, 81, 84, 87, 89, 96, 103, 137, 142, 155, 
159, 165, 168, 171, 177, 185, 190, 193, 196, and 199. 

This code is used in section 2. 

8. While we’re at it, let’s write the program that will look up a word. 
It returns the location of the word in the hash table, or —1 if you’ve 
given a word like ‘tickle’ or ‘terse’ that is unknown. 

^define streq(a,b) (stmcmp(a, b, 5) = 0) 

/* strings agree up to five letters */ 

( Subroutines 6 ) += 

int lookup ARGS((char *)); 
int lookup (w) 

char *w, /* a string that you typed */ 

{ 

register int h\ 
register char *p ; 
register char t; 

t = iu[5]; 

w[5] = ’\0'; /* truncate the word */ 

for (h = 0, p = w; *p\ p++ ) h = *p + h + h; 
h %= hash-prime; /* compute starting address */ 
w[b] = t 4 , /* restore original word */ 

if ( h < 0) return —1; /* a negative character might screw us up */ 

while (hash-table[h], word-type) { 

if (streq(w, hash-table[h\.text)) return h: 

if (h = hash-prime) h = 0; 

} 

return —1; 

} 


ARGS = macro ( ), §3. 

strcpy: char *(), <string.h>. 


stmcmp: int (), <string.h>. 


240 Selected Papers on Fun and Games 

9. The motion words specify either a direction or a simple action or 
a place. Motion words take you from one location to another, when the 
motion is permitted. Here is a list of their possible meanings. 

(Type definitions 5 ) += 

typedef enum { 

N, S , E, W, NE , SE , NW , SW , U, D, L, R, IN , OUT . FORWARD , BACK , 

OVER, ACROSS , UPSTREAM, DOWNSTREAM, 

ENTER , CRAWL , JUMP , CLIMB , LOOK , CROSS , 

ROAD , WOODS , VALLEY , HOUSE , GULLY , STREAM , DEPRESSION , ENTRANCE , CAVE , 
ROCK , SLAB , BED , PASSAGE , CAVERN , CANYON , AWKWARD , SECRET , BEDQUILT , 
RESERVOIR, 

GIANT , ORIENTAL , SHELL , BARREN . BROKEN , DEBRIS , VIEW , FORK , 

PIT , SLIT , CRACK , DOME , HOLE , WALL , HALL , ROOM , FLOOR , 

STAIRS , STEPS , COBBLES , SURFACE , DARK , LOW , OUTDOORS , 

Y2 , XYZZY , PLUGH , PLOVER , OFFICE , NOWHERE 
} motion; 

10. And here is how they enter our vocabulary. 

If I were writing this program, I would allow the word woods, but Don 
apparently didn’t want to. 

( Build the vocabulary 10 ) = 
current-type = motion-type; 
new-word (" north" , N); new-word ("n " , N); 
new-word (" south" , S); new-word (" s" , S); 
new-word (" e ast" , E); new-word ("e " , E); 
new-word ("west" , W); new-word (" w" , W); 
new-word ( "ne" , NE ) ; 
new-Word(" se" , SE); 
new-word ("nw" , NW); 
new.word (" sw" , SW); 

new-Word(" upwar",U); new-word ("up" , U); new-word ("u" ,U); 

neW-Word(" above" ,U); new-word (" aLScen" ,U); 

new-Word(" downw",D); new-word ("down" , D); new-word(" d",D); 

new-word ("desce" , D); 

new-word ("left" , L); 

new-word ("right " , R); 

new-word (" inwar" , IN); new-word ( "insid" , IN); new-word (" in" , IN); 
new-word ("out" , OUT); new-word (" out si" , OUT); 
new-word (" exit" , OUT); 
new-word ( " leave " , OUT ) ; 

new-word ( " f orwa" , FORWARD ) ; new-word ( " cont i " , FORWARD ) ; 
new-word (" onwar" , FORWARD ); 

new-word ("back" , BACK); new-word ("retur" , BACK); 
new-word ( " retre " , BACK ) ; 


THE VOCABULARY 


Adventure 241 


new.word (" over" , OVER); 
new.word(" acros" , ACROSS); 
new.word ("upstr" , UPSTREAM ); 
new.word ( " downs " , DOWNSTREAM ) ; 
new.word (" ent er " , ENTER ) ; 
new-word ( " crawl " , CRAWL ) ; 
new.word (" jump" , JUMP); 
new.word (" climb" , CLIMB); 

new-word (" look" , LOOK); new-word ( "exami" , LOOK); 

new-word ( "touch" , LOOK ) ; new-word ( "descr " , LOOK ) ; 

new-word ("cross", CROSS ) ; 

new-word (" road" , ROAD); 

new-word ( "hill " , ROAD ) ; 

new.word { "fores" , WOODS ); 

new-word ("valle" , VALLEY); 

new-word ( "build" , HOUSE); new.word { "house" , HOUSE); 

new-word ( "gully " , GULLY ) ; 

new.word (" strea" , STREAM); 

new-word ( " depre " , DEPRESSION ) ; 

new-word ( " entra" , ENTRANCE ) ; 

new-word ( " cave " , CAVE ) ; 

new.word ("rock" , ROCK); 

new-word ( " slab " , SLAB ) ; new-word ( " slabr " , SLAB ) ; 
new-word ( "bed" , BED); 

new.word ( "passa" , PASSAGE) ; new.word ( " tunne " , PASSAGE ) ; 

new.word ("caver" , CAVERN); 

new.word ("canyo" , CANYON); 

new.word ( " awkwa" , AWKWARD ) ; 

new.word ( " secre " , SECRET ) ; 

new.word ("bedqu" ,BEDQUILT); 

new.word (" reser " , RESERVOIR) ; 

new.word (" giant" , GIANT); 

new.word(" orien" , ORIENTAL); 

new.word (" shell" , SHELL); 


current-type: wordtype, §7. 
motion.type = 1, §5. 


new.word: void (), §6. 


242 Selected Papers on Fun and Games 

10. (continued) 

new.word ("barre" , BARREN); 
new.word(" broke" , BROKEN); 
new-word ("debri" , DEBRIS); 
new.word("v iew" , VIEW); 
new.word( "fork" , FORK); 
new.word ( "pit" , PIT); 
new.word (" slit" , SLIT); 
new.word{" crack" , CRACK); 
new. word (" dome " , DOME); 
new.word ( "hole" , HOLE); 
new.word ("vail" , WALL); 
new. word ( " hal 1 " , HALL ) ; 
new.word (" room" , ROOM); 
new.word(" floor" , FLOOR); 
new.word(" stair" , STAIRS ); 
new.word ("steps" , STEPS); 
new.word ( " cobbl " , COBBLES ) ; 
new-Word(" surf a" , SURFACE); 
new. word ( " dark " , DARK ) ; 
new.word (" low" , LOW); 
new.word(" outdo" , OUTDOORS); 
new.word (" y2" , Y2); 
new.word("xyzzy " , XYZZY); 
new.word ("plugh" , PLUGH); 
new.word ("plove" , PLOVER); 

new.word ("main" , OFFICE); new.word (" off ic" , OFFICE); 
new.word ("null" , NOWHERE); new.word (" nowhe" . NOWHERE 

See also sections 12, 14, and 16. 

This code is used in section 200. 


THE VOCABULARY 


Adventure 243 


11. The object words refer to things like a lamp, a bird, batteries, 
etc.; objects have properties that will be described later. Here is a 
list of the basic objects. Objects GOLD and higher are the “treasures.” 
Extremely large objects, which appear in more than one location, are 
listed more than once using 

^define min-treasure GOLD 

#define is -treasure (t) ( t > min-treasure) 

#define max-obj CHAIN 
{ Type definitions 5 ) += 

typedef enum { 

NOTHING , KEYS , LAMP , GRATE , GRATE_ , C AGE , ROD , R0D2 , TREADS , TREADS. , 
BIRD, DOOR, PILLOW, SNAKE, CRYSTAL, CRYSTAL. , TABLET, CLAM, OYSTER, 

MAG , DWARF , KNIFE , FOOD , BOTTLE , WATER, OIL , 

MIRROR , MIRROR. , PLANT , PLANT2 , PLANT2. , STALACTITE , SHADOW , SHADOW. , 
AXE , ART , PIRATE , DRAGON , DRAGON. , BRIDGE , BRIDGE. , TROLL , TROLL. , 
TR0LL2 , TR0LL2. , 

BEAR , MESS AGE , GEYSER , PONY , BATTERIES , MOSS , 

GOLD, DIAMONDS , SILVER, JEWELS , COINS, CHEST, EGGS, TRIDENT, VASE, 
EMERALD , PYRAMID , PEARL , RUG , RUG. , SPICES , CHAIN 
} object; 


BARREN =48, §9. 
BROKEN =49, §9. 
COBBLES =64, §9. 
CRACK = 55, §9. 

DARK = 66, §9. 

DEBRIS =50, §9. 

DOME =56, §9. 

FLOOR = 61, §9. 

FORK =52, §9. 

HALL =59, §9. 

HOLE =57, §9. 

LOW = 67, §9. 

new -word , : void (), §6. 

NOWHERE = 74, §9. 


OFFICE = 73, §9. 
OUTDOORS =68, §9. 
PIT = 53, §9. 
PLOVER = 72, §9. 
PLUGH = 71, §9. 
ROOM =60, §9. 

SLIT =54, §9. 
STAIRS =62, §9. 
STEPS = 63, §9. 
SURFACE =65, §9. 
VIEW = 51, §9. 

WALL = 58, §9. 
XYZZY = 70, §9. 

Y2 =69, §9. 


244 Selected Papers on Fun and Games 

12. Most of the objects correspond to words in our vocabulary. 

( Build the vocabulary 10 } 
current-type = object-type-, 

new.word (" key" , KEYS); new-word ("keys" , KEYS); 

new-word ( " lamp " , LAMP ) ; new -word ( " lant e " , LAMP ) ; 

new-word ("headl" , LAMP); 

new-word ( "grate " , GRATE) ; 

new-word ("cage" , CAGE); 

new.word ( "rod" , ROD); 

new-word ("bird" , BIRD); 

new-Word(" door" , DOOR); 

new-word ( "pillo " , PILLOW ) ; 

new-word (" snake " , SNAKE); 

new-word ( "f issu" , CRYSTAL ) ; 

new-word ("table " , TABLET); 

new-word (" clam" , CLAM); 

new.word(" oyste" , OYSTER); 

new-word (" magaz" , MAG); new-word (" issue" , MAG); 
new-word ( " spelu" , MAG ) ; new-word ( " \ " spel " , MAG ) ; 
new-word ( "dwarf " , DWARF ) ; new.word ( " dwarv " , DWARF ) ; 
new-word (" knife" , KNIFE); new.word ("knive" , KNIFE); 
new.word ("food" , FOOD); new.word(" ratio" , FOOD); 
new-word ( "bott 1 " , BOTTLE ) ; new-word ("jar", BOTTLE ) ; 
new-word ("water" , WATER); new-word ("h2o" , WATER); 
new-word (" oil" , OIL); 
new-word (" mirro" , MIRROR); 

new.word ( "plant " , PLANT ) ; new-word ( "beans " , PLANT ) ; 
new-word ("stala" , STALACTITE); 

new-word ( " shado " , SHADOW ) ; new-word ( " f igur " , SHADOW ) ; 

new-word ( " axe " , AXE ) ; 

new-word ("drawi" , ART); 

new-word ("pirat" .PIRATE); 

new-word ("dr ago" , DRAGON); 

new-word ( " chasm" , BRIDGE ) ; 

neuuword ("troll" , TROLL); 

new-word ("bear " , BEAR); 

new-word ("messa" , MESSAGE); 

new-word ("volca" , GEYSER); new.word ("geyse" , GEYSER); 
new.word (" vendi " , PONY); new-word ("machi 11 , PONY); 
new-word ("batte " , BATTERIES); 

new-word ( "mos s " , MOSS ) ; new.word ( " carpe ", MOSS ) ; 
new.word ( "gold" , GOLD); new.word ("nugge" . GOLD); 
new.word ("diamo" .DIAMONDS); 

neiy_irord("silve" , SILVER); new.word ( "bars ", SILVER); 


THE VOCABULARY 


Adventure 245 


new.word ( " j ewel " , JEWELS ) ; 
new.word (" coins" , COINS); 

new.word (" chest" , CHEST); new.word ( "box ", CHEST); 
new.word ("treas" , CHEST); 

new.word ( " eggs " , EGGS ) ; new. word ( " egg" , EGGS ) ; 
new.word(" nest" , EGGS); 
new.word (" tride" , TRIDENT); 

new.word ( "ming " , VASE); new.word ( " vase " , VASE ) ; 
new.word ( " shard" , VASE) ; new.word ( "potte " , VASE) ; 
new.word("e mera" , EMERALD); 

new.word ( "plat i " , PYRAMID ); new.word ( "pyram" , PYRAMID ) ; 
new.word ( "pearl" , PEARL); 

new.word ("persi" , RUG); new.word ("rMg" , RUG); 
new.word ("spice" , SPICES ); 
new.word ( " chain" , CHAIN ) ; 


ART = 35, §11. 

LAMP = 2, §11. 

AXE = 34, §11. 

MAG = 19, §11. 

BATTERIES = 49, §11. 

MESSAGE =46, §11. 

BEAR = 45, §11. 

MIRROR = 26, §11. 

BIRD = 10, §11. 

MOSS = 50, §11. 

BOTTLE = 23, §11. 

new.word: void (), §6. 

BRIDGE =39, §11. 

object.type =2, §5. 

CAGE =5, §11. 

OIL = 25, §11. 

CHAIN =66, §11. 

OYSTER = 18, §11. 

CHEST = 56, §11. 

PEARL = 62, §11. 

CLAM = 17, §11. 

PILLOW = 12, §11. 

COINS =55, §11. 

PIRATE = 36, §11. 

CRYSTAL = 14, §11. 

PLANT = 28, §11. 

current. type-, wordtype, §7. 

PONY =48, §11. 

DIAMONDS =52, §11. 

PYRAMID =61, §11. 

DOOR = 11, §11. 

ROD = 6, §11. 

DRAGON =37, §11. 

RUG = 63, §11. 

DWARF = 20, §11. 

SHADOW =32, §11. 

EGGS = 57, §11. 

SILVER = 53, §11. 

EMERALD =60, §11. 

SNAKE = 13, §11. 

FOOD = 22, §11. 

SPICES =65, §11. 

GEYSER = 47, §11. 

STALACTITE = 31, §11. 

GOLD = 51, §11. 

TABLET = 16, §11. 

GRATE =3, §11. 

TRIDENT = 58, §11. 

JEWELS =54, §11. 

TROLL =41, §11. 

KEYS = 1, §11. 

VASE = 59, §11. 

KNIFE = 21, §11. 

WATER = 24, §11. 


246 Selected Papers on Fun and Games 

13. The action words tell us to do something that’s usually nontrivial. 

( Type definitions 5 ) += 

typedef enum { 

ABSTAIN , TAKE , DROP , OPEN , CLOSE , ON , OFF , WAVE , CALM , GO , RELAX , 

POUR , EAT , DRINK , RUB , TOSS , WAKE , FEED , FILL , BREAK , BLAST , KILL , 

SAY, READ , FEEFIE , BRIEF , FIND , INVENTORY , SCORE , QUIT 
} action; 

14. Many of the action words have several synonyms. If an action 
does not meet special conditions, we will issue a default message, 
^define ok default-ms 3 [RELAX] 

( Build the vocabulary 10 } += 
current-type = action-type ; 

new-word (" take" , TAKE); neui-word (" carry " , TAKE); 
new-Word( "keep" , TAKE); nev>-Word(" catch" , TAKE); 
new-word ("captu" , TAKE); new-word (" steal" , TAKE); 
neui-word ( "get" , TAKE); new-word ( "tote" , TAKE); 
default-ms g [TAKE] = "You u are u already u carrying u it ! " ; 
new-word ( "drop" , DROP); new-word (" relea" , DROP); 
neui-word ("free" , DROP); new-word ("disca" , DROP); 
new-word (" dump" , DROP); 

default-msg [DROP] = "You u aren’tijCarrying u it ! " ; 
new-word {" open" , OPEN); new.word ("unloc" , OPEN); 
default-msg [OPEN] = "I u don’t u know u how u to u lock u \ 
or u unlock u such u a u thing. " ; 
new-word (" close " , CLOSE); new-word(" lock" , CLOSE); 
default-msg [CLOSE] = default-msg [OPEN]; 
new-word ("light" , ON); new-word (" on" , ON); 
default-msg[ON] = "YoUuhave u no u source u of u light . " ; 
new-word ("er tin" , OFF); new-word (" of f " , OFF); 
default-msg [OFF] = default-msg [OH]-, 
new-word ("wave" , WAVE); new-word (" shake " , WAVE); 
new-Word(" swing" , WAVE); 
default-msg [WAVE] = "Nothing u happens . " ; 
new-word (" calm" , CALM); new-word ("placa" , CALM); 
new-word (" tame" , CALM); 

default-msg [CALM] = "I ’m u game . uu Would u you u care u to u explain u how?" ; 
new- word ("walk" , GO); new-word ( "run" , GO); new-word ("trave" , GO); 
new-word (" go" , GO); new-word ("proce" , GO); new-word ("explo" , GO); 
new-Word(" goto" , GO); new-word (" folio" , GO); new-word ("turn" , GO); 
default-msg [GO] = "Where?"; 
new-word ("nothi" , RELAX); 
default-msg [RELAX] = "OK."; 
new-word ( "pour" , POUR); 


THE VOCABULARY 


Adventure 247 


default-msg [POUR] = default-msg [DROP]; 
new-word ("eat" , EAT); new-word (" devou" , EAT); 
default-msg [EAT] = "Don’t u be u ridiculous ! " ; 
new. word ("drink" , DRINK); 

default-msg [DRINK] = "You u have u taken u a u drink u from u the u stream.uu\ 
The u water u tastes u strongly u of \n\ 
minerals , u but u is u not u unpleasant . uu It u is u extremely u cold . " ; 

new -word (" rub" , RUB); 

default-ms g [RUB] = "Rubbing u the u electric u lamp u \ 

is u not u part icularly u rewarding . uu Anyway , \n\ 
nothing u exciting u happens . " ; 
new-Word(" throw" , TOSS); new-Word(" toss" , TOSS); 
default-msg [TOSS] = "Peculiar . U uNothing u unexpected u happens ; 
new-word ("wake" , WAKE); new-word (" distu" , WAKE); 
default-msg [WAKE] = default-msg [EhT]; 
new-word (" feed" , FEED); 

default-msg [FEED] = "Thereuisunothinguhereutoueat . 11 ; 
new-word ( "fill" , FILL); 

default-msg [FILL] = "Youucan’tuf ill u that . " ; 
new-word ("break" , BREAK); new- word ("smash" , BREAK); 
new-word ( " shatt " , BREAK ) ; 

default-msg [BREAK] = "Ityisubeyonduyourupowerutoudouthat . " ; 
new-word ( "blast" , BLAST); new-word (" deton" , BLAST); 
new-word ("ignit" , BLAST); new- word ("blowu" , BLAST); 
default-msg [BLAST] = "Blasting u requires u dynamite . " ; 
new-word (" attac" , KILL); new-word (" kill" , KILL); 
new-word ( "fight" , KILL); new-word ( "hit" , KILL); 
new-word ("strik" , KILL); new-Word(" slay" , KILL); 
default-msg [KILL] = default-msg [EAT]; 


action-type = 3, §5. 

BLAST, see §99. 

BREAK, see §101. 

CLOSE, see §93 and §130. 
current-type : wordtype, §7 
default-msg: char *[], §15. 
DRINK, see §106. 

DROP, see §117. 

EAT, see §92 and §98. 

FEED, see §129. 

FILL, see §79 and §110. 

GO, see §79. 



248 Selected Papers on Fun and Games 

14. (continued) 

new-Word(" say" , SAY); new-Word( "chant" , SAY); new-Word(" sing" , SAY); 
neW-Word( "utter" , SAY); new-Word(" mumbl" , SAY); 
new-Word(" read" , READ); new-word ("perus" , READ); 
default.msg [READ] = "I ’muafraid u Iudon’t u understand. " ; 
new-word ("fee" , FEEFIE); new-word (" fie" , FEEFIE); 
new.word ("foe" , FEEFIE); new-word (“f oo" , FEEFIE); 
new-word ("f\m" . FEEFIE); 
defaultjmsg [FEEFIE] = "I u don’t u know u how. " ; 
new-word ("brief" , BRIEF); 
default-msg [BRIEF] = "On u what?"; 
new-word ("find" , FIND); new-word (" where" , FIND); 
default-msg[ FIND] = "I u can u only u tell u you u what u you u see u \ 
as u you u moveuabout u and u manipulate\n\ 
things . uu I u cannot u tell u you u uhere u remote u things u are . " ; 
new-word ("inven" , INVENTORY); 
default-msg [INVENTORY ] = defaultjmsg [FIND] ; 
neW-Word(" score" , SCORE); 
default-msg [SCORE] = "Eh?"; 
new-word (" quit" , QUIT); 
default-msg[ QUIT] = default-msg [SCORE]; 

15. (Global variables 7) += 

char *default-msg[ 30]; /* messages for untoward actions, if nonzero */ 

16. Finally, our vocabulary is rounded out by words like help, which 
trigger the printing of fixed messages. 

^define new-mess(x ) message[k++] = x 
#deflne mess-wd ( w ) new-U>ord (w, k) 

(Build the vocabulary 10 ) += 
current-type = message-type ; 
k = 0; 

mess-wd ( " abra" ) ; mess-wd ( " abr ac " ) ; 

mess-wd ("opens" ); mess-wd(" sesam"); mess_u>d("shaza" ); 
mess-wd ("hocus" ); mess-wd ("pocas " ); 

new-mess ("Good u try , u but u that u is u an u old u worn-out u magic u word . " ); 
mess-wd ( "help " ) ; mess.wd ("?"); 

neuLmess("I u know u of u places , u actions , u and u things . uu \ 

Most u of u my u vocabulary\n\ 

describes u places u and u is u used u to u moveuyou u there . uu \ 

To u raove , u try u words\n\ 

like u f orest , u building, u downstream, u enter , u east , u west )U \ 
north , u south , \n\ 

up , u or u down . uu I u know u about u a u f ew u special u ob j ects , u \ 
like u a u black u rod\n\ 


THE VOCABULARY 


Adventure 249 


hidden u in u the u cave . uu These u objects u can u t>e u manipulated u \ 
us ing u some u of \n \ 

theuactionuWordSuthatuIuknow.uijUsuallyuyouuwilluX 
need u to u give u both u the\n\ 
object u and u action u words u (in u either u order) , u \ 
but u sometimes u I u can u inf er\n\ 
the u ob j ect u f rom u the u verb u alone . uu \ 

Some u objects u also u imply u verbs ; u in\n\ 
particular , u \" invent ory\" u implies u \"take u inventory\" , u \ 
which u causes u me u to\n\ 

give u you u a u list u of u Mhat u you’re u carrying.|j U \ 

The u objects u have u side\n\ 

ef f ects ; u f or u instance , u the u rod u scares u the u bird. uu \ 
Usually u people u having\n \ 

trouble u moving u justuneedutOutryuauf ew u more u words . uu \ 
Usually u people\n\ 

trying u unsuccessfully u to u manipulate u anuObject u \ 
are u at tempt ing u something\n\ 
beyond u their u (or u my ! )ucapabilities u and u shouldu\ 
try u a u completely\n\ 

dif f erent u tack. uu To u speed u the u gcime u you u can u sometimes u \ 
move u long\n\ 

distancesuwithuausingleuword . uu For u example , u \ 
\"building\" u usually u gets\n\ 
you u to u the u building u f rom u anywhere u above u ground u \ 
except u when u lost u in u the\n\ 
forest . uljAIso , u note u that u cave u passages u turn u a u lot , u \ 
and u that u leaving u a\n\ 

room u to u the u north u does u not u guarantee u entering u \ 
the u next u f rom u the u south . \n\ 

Good u luck! " ); 


BRIEF, see §95. 
current-type: wordtype, §7. 
FEEFIE, see §136. 

FIND, see §100. 

INVENTORY, see §94 and §100. 
k: register int, §2. 
message : char *[], §17. 


message-type = 4, §5. 
new-word: void (), §6. 
QUIT, see §95. 

READ, see §93 and §135. 
SAY, see §97. 

SCORE, see §95. 


250 


Selected Papers on Fun and Games 
16 . (continued) 

mess-wd ("tree" ); mess-.wd (" trees" ); 
new-Tness ("The u trees u of u the u f or est u are u large u \ 
hardwood u oak u and u maple , u with u an\n\ 
occasional u grove u of u pine u or u spruce . uu \ 
There u is u quite u a u bit u of u under-\n\ 
growth, u largely u birch u cmd u ash u saplings u \ 
plus u nondescript u bushes u of \n\ 
various u sorts . uu This u time u of u year u \ 

visibility u is u quite u restricted u by\n\ 
all u the u leaves , u but u travel u is u quite u easy u \ 
if u you u detour u around u the\n\ 
spruce u and u berry u bushes . " 
mess-wd ( " dig" ) ; mess-wd ( " excav " ) ; 

netu_mess("Digging u without u a u shovel u is u quite u impractical . uu \ 
Even u with u a u shovel\n\ 
progress u is u unlikely . " ) ; 
mess-wd ("lost " ); 

ne«;_mess("I ’muasuconfuseduasuyouuare . " ); 
new.mess ("Thereuis u a u louduexplosion u and u \ 

you u are u suddenly u splashed u across u the\n\ 
walls u of u the u room. " ); 

ne«;_TOe«s("There u is LJ aulouduexplosion u and u \ 

a u twenty-f ootuholeuappearsuinutheuf ar\n\ 
wall , u bury ing u the u snakes u in u the u rubble . uu \ 

A u river u of u molten u lava u pours\n\ 
in u through u the u hole , u \ 

destroying u everythinguin u its u path,uincluding u you! " ); 
mess-wd ( "mist " ) ; 

new-mess ( "Mist u is u a u white u vapor , u usually u water , u \ 
s een u f r om u t ime u t o u t ime u in\n \ 
caverns . uu It u can u be u f ound u cLnywher e u \ 

but u is u f requently u a u sign u of u a u deep\n\ 
pit u leading u down u to u water . " ); 
mess.wd ("fuck" ); new-mess ("Wat ch u it ! " ); 
new.mess ( "There u is u a u loud u explosion , u and u \ 

a u twenty-f oot u hole u appears u in u the u f ar\n\ 
wall , u burying u the u dwarves u in u the u rubble , uu \ 
You u march u through u the u hole\n\ 
and u f ind u your self u in u the u main u off ice , u \ 
where u a u cheer ing u band u of \n \ 
friendly u elves u carry u the u conquering u adventurer u \ 
off u into u the u smiset . " 
mess-wd ( " stop" ) ; 


THE VOCABULARY 


Adventure 251 


new.mess ( " I u don ’ t u know u the u word u \ " st op\ " . uu \ 

Use u \"quit\" u if u you u want u to u give u up. " ); 
mess-wd ( " inf o " ) ; mess-wd ( " inf or " ) ; 
raeiD_mess("If u you u want u to u enduyour u adventure u early , u \ 
say u \"quit\" . uu To u get u full\n\ 
credit u f or u a u treasure .uyoUumustuhaveuX 
lef t u it u saf ely u in u the u t>uilding , \n\ 
though u you u get u partial u credit u just u f or u \ 
locating u it . uu You u lose u points\n\ 
f or u gett ing u killed , u or u f or u quitt ing , u \ 

though u the u f ormer u costSuyou u more . \n\ 
There u are u also u points u based u on u how u much u \ 

(if u any) u of u the u cave u you’ ve\n\ 
managed u to u explore ; u in u part icular , u \ 

there u is u a u large u bonus u just u f or\n\ 
getting u in u (to u distinguish u the u beginners u \ 
from u the u rest u of u the u pack) ,\n\ 
and u there u are u other u waysuto u determineu\ 
whether u you’ ve u been u through u some\n\ 
of u the u more u harrowing u sections . U u\ 

If u you u think u you ’ ve u f ound u all u the\n\ 
treasures , u just u keep u exploringufor u a u while . uu \ 

If u nothing u interesting\n\ 
happens , u you u haven’t u found u them u all u yet . uu \ 

If u something u interesting\n\ 

DOES u happen , u it u means u you ’ re u gett ing u a u bonus u \ 
and u have u an u opportunity\n\ 

tougarnerumanyumoreupointsuinutheumaster ’ s u section. \n\ 
I u may u occasionallyuOf f er u hints u if u you u seem u \ 
to u be u having u trouble . \n\ 

If Ljludo ,ul ’ll u warn u you u in u advance u hoM u muchij\ 
it u will u aff ect u your u score\n\ 
to u accept u the u hints . U uFinally , u to u save u paper , u \ 
you u may u specif y u \"brief \" ,\n\ 
whichutellsumeijneverutOijrepeatutheufulluX 
description u of u a u place\n\ 
unless u you u explicitly u ask u me u to . " 
mess-wd ( " swim" ) ; 
new-mess ( " I u don ’ t u know u how . " ) ; 

17. (Global variables 7) += 

char * message [13]; /* messages tied to certain vocabulary words */ 


_ 


mess-wd = macro ( ), § 16 . 


new -mess — macro ( ), § 16 . 


252 Selected Papers on Fun and Games 

18. Cave data. You might be in any of more than 100 places as 
you wander about in Colossal Cave. Let’s enumerate them now, so that 
we can build the data structures that define the travel restrictions. 

A special negative value called inhand is the location code for objects 
that you are carrying. But you yourself are always situated in a place 
that has a nonnegative location code. 

Nonnegative places < outside are outside the cave, while places > 
inside are inside. The upper part of the cave, places < emist, is the 
easiest part to explore. (We will see later that dwarves do not venture 
this close to the surface; they stay > emist.) 

Places between inside and dead2, inclusive, form the main cave; the 
next places, up to and including barr, form the hidden cave on the other 
side of the troll bridge; then neend and swend are a private cave. 

The remaining places, > crack, are dummy locations, not really part 
of the maze. As soon as you arrive at a dummy location, the program 
immediately sends you somewhere else. In fact, the last three dummy 
locations aren’t really even locations; they invoke special code. This 
device is a convenient way to provide a variety of features without 
making the program logic any more cluttered than it already is. 

^define minAn-cave inside 

# define minJowerJoc emist 

# define min-forced-loc crack 
^define maxJoc didit 
#define maxspec troll 

(Type definitions 5) += 
typedef enum { 

inhand = —1, limbo, 

road, hill, house, valley , forest , woods, slit, outside, 
inside, cobbles, debris, awk, bird, spit, 
emist , nugget , efiss , wfiss , wmist , 

likel , Uke2 , UkeS , likef , like5 , Uke6 , like? , like8 , like 9 , UkelO , likell , 
likel2 , likel 3 , likelf , 
brink, elong, wlong, 

diffO , diffl , diff2 , diff3 , diff4 , diff5 , diff6 , diff 7 , diff8 , diff9 , diffl 0 , 

pony , cross , hmk , west , south ,ns,y2, jumble , windoe , 

dirty, clean, wet, dusty, complex, 

shell, arch, ragged, sac, ante, witt, 

bedquilt, cheese, soft, 

e2pit , w2pit , epit , wpit , 

narrow , giant , block , immense , falls , steep , 

abovep, sjunc, tite, low , crawl, window, 

oriental , misty , alcove , proom , droom , 


CAVE DATA 


Adventure 253 


slab, abover, mirror , res, 
scanl , scan2 , scan3 , secret , 
wide , tight, tall, boulders, 
scorr, swside , 

deadO , deadl , dead2 , deadS , dead4 , dead5 , dead6 , dead! , dead8 , dead9 , 
deadlO , deadl 1 , 

neside, corr , fork, warm, view, chamber, lime , fbarr , barr, 
neend, swend, 

crack, neck, lose, cant, climb, check, snaked, thru, duck, sewer, upnout, 
didit , 

ppass , pdrop , troll 

} location; 





road, §23 (022) = likeS, §36 (043) = diff6, §39 (064) = ragged, §43 (085) = crawl, §48 (106) = deadO, §56 

hill, §24 (023) = like4, §36 (044) = diff 7, §39 (065) = sac, §43 (086) = window, §49 (107) = deadl, §56 

house, §25 (024) = like5, §36 (045) = diff8, §39 (066) = ante, §44 (087) = oriental, §50 (108) = deadS, §56 

valley, §26 (025) = like6, §36 (046) = diff9, §39 (067) = witt, §44 (088) = misty, §50 (109) = deadS, §56 


CAVE DATA 


Adventure 255 



lO W lO 
coo coo coo eq 
lO 


CO CO CO CO 
lO lO lO lO •'tf 



CO CO CO CO 
COCOCOCOCOCOCOCO 
CO CO CO coo coo coo coo coo 
coo coo coo ^ „ 

_ „ . O O) CCi > - 

5)0001)000,^ 


oo 


coo coo 

eK O) 

c g ^ ^ ^ 
o -2 ^ 

"55 5 



CN <N 
coo coo qo 

HO «T CM 
C0 “CS coo 

cu o 


05 rH 

CM O CO 1-1 
M tco CO 

^ COO _ COO t— I r-H ,_| 

- CO , CO CO CO 

^ -2 -S c-co coo H«r 

! 1 1 1 -« -g- .or | 


CO 
CM CO 
CO COO T}< 
coo 


■'tf CO CO CO 

CO coo c0 CO 

COO r COO coo 


*^5 CO .2 £ ‘U ^ 


I * 


256 Selected Papers on Fun and Games 

19. Speaking of program logic, the complex cave dynamics are essen- 
tially kept in a table. The table tells us what to do when you ask for 
a particular motion in a particular location. Each entry of the table is 
called an instruction; and each instruction has three parts: a motion, a 
condition, and a destination. 

The motion part of an instruction is one of the motion verbs enumer- 
ated earlier. 

The condition part c is a small integer, interpreted as follows: 

• if c = 0, the condition is always true; 

• if 0 < c < 100, the condition is true with probability c/100; 

• if c = 100, the condition is always true, except for dwarves; 

• if 100 < c <= 200, you must have object c mod 100; 

• if 200 < c <= 300, object c mod 100 must be in the current place; 

• if 300 < c <= 400, prop[c mod 100] must not be 0; 

• if 400 < c <= 500, prop[c mod 100] must not be 1; 

• if 500 < c <= 600, prop[c mod 100] must not be 2; etc. 

(We will discuss properties of objects and the prop array later.) 

The destination d is either a location or a number greater than 
max Joe. In the latter case, if d < maxspec we perform a special rou- 
tine; otherwise we print remarks[d — maxspec] and stay in the current 
place. 

If the motion matches what you said but the condition is not satisfied, 
we move on to the next instruction that has a different destination 
and/or condition from this one. The next instruction might itself be 
conditional in the same way; but the motion is no longer checked after 
it has first been matched. (Numerous examples appear below; complete 
details of the table-driven logic can be found in section 146.) 

{ Type definitions 5 ) += 
typedef struct { 

motion mot; /* a motion you might have requested */ 
int cond ; /* if you did, this condition must also hold * / 

location dest ; /* and if so, this is where you’ll go next */ 

} instruction; 


CAVE DATA 


Adventure 257 


20. Suppose you’re at location Z. Then start[l] is the first relevant 
instruction, and start[l+ 1]-1 is the last. Also long.desc[l\ is a string that 
fully describes Z; short-desc[l ] is an optional abbreviated description; and 
visits [Z] tells how many times you have been here. Special properties of 
this location, such as whether a lantern is necessary or a hint might be 
advisable, are encoded in the bits of flags [l]. 


#define 

lighted 1 

/* 

#define 

oil 2 

/* bit 

^define 

liquid 4 

/* ' 

^define 

cave-hint 

8 

#define 

bird-hint 

16 

^define 

snake-hint 

32 

^define 

twist-hint 

64 

^define 

dark-hint 

128 

# define 

witt-hint 

256 

^define 

travel-size 

740 

#define 

remsize 

15 


*/ 


/* bit for hint about trying to get in the cave */ 
/* bit for hint about catching the bird */ 

/* bit for hint about dealing with the snake */ 
/ * bit for hint about being lost in a maze * / 

/* bit for hint about the dark room */ 

/* bit for hint about Witt’s End */ 

/* at most this many instructions */ 

/* at most this many remarks */ 


( Global variables 7 ) += 

instruction travels [travelsize]', /* the table of instructions */ 
instruction *start[maxJoc + 2]; 

/ * references to starting instruction * / 
char *long-desc[maxJoc + 1]; 

/* long-winded descriptions of locations */ 
char *short-desc[maxJoc + 1]; /* short-winded descriptions, or 0 */ 

int flags [max Joe + 1]; /* bitmaps for special properties */ 

char * remarks [remsize]; /* comments made when staying put */ 

int rem.count; /* we’ve made this many comments */ 
int visits [max Joe + 1]; /* how often have you been here? */ 


location = enum, §18. 
maxJoc = 140, §18. 
max-spec = 143, §18. 


motion = enum, §9. 
newloc : location, §74. 
prop: int [], §63. 


258 Selected Papers on Fun and Games 

21. Cave connections. Now we are ready to build the fundamental 
table of location and transition data, by filling in the arrays just declared. 
We will fill them in strict order of their location codes. 

It is convenient to define several macros and constants. 

^define makeJoc(x,l, s, f) 

{ long-desc[x] = l; short_desc[x] — s; flags[x] = f; start [x] = q; } 
^define makeJnst (m, c, d) 

{ q-mot = m; q-cond = c; q-dest = d; q++; } 

^define ditto (m) 

{ q-mot = to; q-cond = (q — 1 )-cond; q-dest = (q — 1 )-dest; 

<?++; } 

^define holds (o) (100 + (o) ) 

/* do instruction only if carrying object o */ 

#define sees(o) (200 + (o)) 

/* do instruction only if object o is present */ 

#define not(o, k) (300 + (o) + 100 * ( k )) 

/* do instruction only if prop[o] / k */ 

^define remark (to) remarks [++ rem-count] = m 
^define sayit ( maxspec + rem-count) 

( Global variables 7 ) += 
char alLalike[] = 

"You u are u in u a u maze u of u twisty u little u passages, u all u alike . " ; 
char dead-end[ \ = "Dead u end. " ; 
int slit-rmk, grate.rmk, bridge_rmk , loop^rmk; 

/* messages used more than once */ 

22. (Additional local registers 22 ) = 
register instruction *q, *qq ; 

See also sections 68 and 144. 

This code is used in section 2. 

23. The road is where you start; its long^desc is now famous, having 
been quoted by Steven Levy in his book Hackers. 

The instructions here say that if you want to go west, or up, or on the 
road, we take you to hill ; if you want to go east, or in, or to the house, 
or if you say ‘enter’, we take you to house ; etc. Of course you won’t 
know about all the motions available at this point until you have played 
the game for awhile. 

( Build the travel table 23 ) = 
q = travels; 
make Joe (road , 

"You u are u standing u at u the u end u of u a u road u \ 

bef ore u a u small u br ick u building . \n \ 

Around u you u is u a u f orest . uu \ 


CAVE CONNECTIONS 


Adventure 259 


A u small u stream u flows u out u of u the u building u and\n\ 
down u a u gully . " , 

" You ’ re u at u end u of u road u again . " , lighted + liquid ); 
makeAnst)V,0, hill); ditto (U); ditto (ROAD); 
makeAnst (E, 0, house ) ; ditto (IN); ditto(HOUSE); ditto (ENTER); 
makeAnst)S, 0, valley); ditto) D); ditto(GULLY); ditto (STREAM); 
ditto (DOWNSTREAM); 
makeAnst (N, 0, forest ) ; ditto (WOODS ) ; 
makeAnst (DEPRESSION , 0, outside ); 

See also sections 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 
43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, and 62. 
This code is used in section 200. 

24. There’s nothing up the hill, but a good explorer has to try anyway. 

( Build the travel table 23 ) += 
make Joe (hill , 

" You u have u walked u up u a u hill, u st ill u in u the u f orest -uu\ 

The u road u slopes u back\n\ 
down u the u other u side u of u the u hill . UL) \ 

There u is u a u building u in u the u distance. " , 
"You’re u at u hill u in u road. " , lighted)', 

makeAnst (R0 AD , 0, road ) ; ditto (HOUSE); ditto (FORWARD); ditto (E); ditto) D); 
mofce.inst (WOODS, 0, forest)-, ditto) N); ditto) S); 


cond: int, §19. 

D = 9, §9. 

DEPRESSION = 32, §9. 
dest : location, §19. 
DOWNSTREAM = 19, §9. 

E = 2, §9. 

ENTER = 20, §9. 
flags: int [], §20. 
forest =5, §18, §27. 
FORWARD = 14, §9. 

GULLY = 30, §9. 
hill =2, §18, §24. 

HOUSE = 29, §9. 
house = 3, §18, §25. 

IN = 12, §9. 

instruction = struct , §19. 
lighted = 1, §20. 
liquid = 4, §20. 

location = enum, §18. 


long-desc : char *[], §20. 
max-spec = 143, §18. 
mot: motion, §19. 

N = 0, §9. 

outside =8, §18, §29. 
prop: int [], §63. 
rem-count: int, §20. 
remarks: char *[], §20. 
ROAD = 26, §9. 
road = 1, §18, §23. 

S = l, §9. 

short-desc: char *[], §20. 
start: instruction *[], §20. 
STREAM = 31, §9. 
travels: instruction [], §20. 
U = 8, §9. 

valley = 4, §18, §26. 

W = 3, §9. 

WOODS =27, §9. 


260 Selected Papers on Fun and Games 

25. The house initially contains several objects: keys, food, a bottle, 
and a lantern. We’ll put them in there later. 

Two magic words are understood in this house, to teleport spelunkers 
who have been there and done that. (Crowther is said to have pro- 
nounced the first one “zizzy”; the pronunciation of the other one is 
unknown.) 

( Build the travel table 23 ) += 
make Joe (house , 

"You u are u inside u a u building, u auWell u house u f or u a u large u spring . " , 

"You’re u inside u building. " , lighted + liquid); 

make Jnst (ENTER, 0, road); ditto) OUT); ditto (OUTDOORS); ditto (V); 

makednst (XYZZY, 0, debris); 

makednst (PLUGH , 0 ,y2); 

makednst (DOWNSTREAM, 0, sewer); ditto (STREAM ); 

26. A foolish consistency is the hobgoblin of little minds. (Emerson) 

( Build the travel table 23 ) += 

makedoc (valley , 

"You u are u in u a u valley u in u the u f orestuX 

besideuauStreamutumblingualonguaXnX 
rocky u bed . " , 

"You’re u in u valley . " , lighted + liquid); 
makednst (UPSTREAM, 0, road); ditto (HOUSE); ditto) N); 
makednst)V00DS,0, forest); ditto) E); ditto) W); ditto)\J); 
makednst (DOWNSTREAM, 0, slit); ditto) S); ditto (D); 
makednst (DEPRESSION , 0, outside ) ; 

27. The instructions here keep you in the forest with probability 50%, 
otherwise they take you to the woods. This gives the illusion that we 
maintain more state information about you than we really do. 

( Build the travel table 23 ) += 
makedoc ) forest , 

"You u are u in u open u forest , u with u a u deep u valley u to u one u side . " , 

"You’re u in u forest . " , lighted); 

makednst (VALLEY, 0, valley); ditto) E); ditto) D); 

makednst)\!00T>S,50,forest); ditto (FORWARD); ditto) N); 

makednst (WOODS , 0, woods ) ; 

makednst )\t,Q, forest); ditto) S); 

makedoc ( woods , 

"You u are u in u open u forest u near u both u a u valley u and u a u road. " , 

short.desc(f orest], lighted); 
makednst (R0 AD , 0, road); ditto) N) ; 

makednst )V ALLEY , 0, valley); ditto) E); ditto) W); ditto) D); 
makednst (WOODS, 0, forest); ditto) S); 


CAVE CONNECTIONS 


Adventure 261 


28. You’re getting closer. (But the program has forgotten that 
DEPRESSION leads outside ; it knew this when you were at the road or 
the valley.) 

{ Build the travel table 23 ) += 
make Joe (slit , 

"At u your u f eet u all u the u water u of u the u stream u \ 
splashes u into u a u 2-inch u slit\n\ 
irL u the u rock.uuDownstream u the u strearabed u is u bare u rock. " , 
"You’re u at u slit u in u streambed. " , lighted + liquid)', 
makeJnst (HOUSE, 0, road); 
makeJnst (UPSTREAM , 0, valley ) ; ditto (N) ; 
makeJnst (WOODS, 0, forest); ditto (E); ditto) W); 

makeJnst (DOWNSTREAM, 0, outside); ditto) ROCK); ditto (BED); ditto) S); 
remarfc("You u don’t u f it u through u a u two-inch u slit ! " ); 
maA;e_inst (SLIT, 0, sayit); ditto (STREAM); ditto) D); 
slit-rmk = sayit; 


BED = 37, §9. 

D = 9, §9. 

debris = 11, §18, §31. 
DEPRESSION = 32, §9. 
ditto = macro ( ), §21. 
DOWNSTREAM = 19, §9. 

E = 2, §9. 

ENTER = 20, §9. 
forest = 5, §18, §27. 
FORWARD = 14, §9. 
house = 3, §18. 

HOUSE = 29, §9. 
lighted = 1, §20. 
liquid = 4, §20. 
makeJnst = macro (), §21. 
make Joe = macro ( ), §21. 
N = 0, §9. 

OUT = 13, §9. 

OUTDOORS = 68, §9. 
outside =8, §18, §29. 
PLUGH = 71, §9. 


remark = macro ( ), §21. 
ROAD = 26, §9. 
road = 1, §18, §23. 

ROCK =35, §9. 

S = l, §9. 

sayit = macro, §21. 
sewer = 138, §18, §61. 
short-desc: char *[], §20. 
SLIT = 54, §9. 
slit = 7, §18, §28. 

STREAM =31, §9. 

U = 8, §9. 

UPSTREAM = 18, §9. 
VALLEY = 28, §9. 

valley = 4, §18, §26. 

W = 3, §9. 

WOODS =27, §9. 
woods = 6, §18. 

XYZZY = 70, §9. 

1/2 = 54, §18, §41. 


262 Selected Papers on Fun and Games 

29. We’ll see later that the GRATE will change from state 0 to state 1 
if you unlock it. So let’s hope you have the KEYS. 

( Build the travel table 23 } += 
make-loc ) outside , 

"You u are u in u a u 20-f oot u depression u \ 

floor ed u with u bare u dirt . uu Set u into u the\n\ 
dirt u is u a u strong u steel u grate u \ 

mounted u in u concrete . U uAudry u streambed\n\ 
leads u into u the u depression. " , 

"You’re u outside u grate . " , lighted + cave-hint ); 
make.inst (WOODS, 0, forest)] ditto( E); ditto( W); ditto( S); 
makeAnst (HOUSE, 0, road)-, 

make.inst (UPSTREAM , 0, slit ) ; ditto (GULLY ) ; ditto (N); 

make.inst (ENTER, not (GRATE, 0), inside)-, ditto(ENTER); ditto) IN); ditto) D); 
remarfc("You L1 can , t u go u through u a u lockeduSteel u grate ! " ); 
grate.rmk = sayit; 
make.inst (ENTER , 0, sayit ) ; 

30. If you’ve come this far, you’re probably hooked, although your 
adventure has barely begun. 

( Build the travel table 23 ) += 
make.loc ) inside , 

"You u are u in u a u small u chamber u \ 

beneath u a u 3x3 u steel u grate u to u the u surf ace . \n\ 
Aulowucrawluoverucobblesuleadsuinwardsutoijtheuwest . " , 
"You’reubelowutheugrate . " , lighted)-, 

make.inst (OUT, not (GRATE, 0), outside)-, ditto) OUT); ditto) U); 
make.inst)0\JT ,0, grate.rmk)-, 

make.inst (CRAWL, 0, cobbles); ditto (COBBLES); ditto(lN); ditto) W); 
make.inst (PIT , 0, spit)-, 
make.inst) DEBRIS, 0, debris)-, 


CAVE CONNECTIONS 


Adventure 


263 


cave-hint = 8, §20. 
COBBLES = 64, §9. 
cobbles = 10, §18, §31. 
CRAWL = 21, §9. 

D = 9, §9. 

DEBRIS =50, §9. 
debris = 11, §18, §31. 
ditto = macro ( ), §21. 
E = 2, §9. 

ENTER = 20, §9. 
forest = 5, §18, §27. 
GRATE =3, §11. 

GULLY = 30, §9. 

HOUSE =29, §9. 

IN = 12, §9. 
inside = 9, §18, §30. 
KEYS = 1, §11. 
lighted = 1, §20. 


makeAnst = macro (), §21. 
makeJoc = macro (), §21. 
N = 0, §9. 

not = macro ( ), §21. 

OUT = 13, §9. 
outside = 8, §18, §29. 

PIT = 53, §9. 

remark = macro ( ), §21. 

road = 1, §18, §23. 

S = l, §9. 

sayit = macro, §21. 
slit = 7, §18, §28. 
spit = 14, §18, §31. 

U = 8, §9. 

UPSTREAM = 18, §9. 

W = 3, §9. 

WOODS = 27, §9. 


264 Selected Papers on Fun and Games 

31. Go West, young man. (If you’ve got a lamp.) 

( Build the travel table 23 ) += 
make Joe ( cobbles , 

" You u are u crawling u over u cobbles u in u a u low u passage . uu \ 
There u is u a u dim u light\n\ 
at u the u east u end u of u the u passage . " , 

"You’re u in u cobble u crawl . " , lighted)-, 

makednst )0\n , 0, inside)-, ditto (SURFACE); ditto (NOWHERE); ditto) E ) ; 
make dnst (IN, 0, debris)-, ditto(DARK); ditto) W); ditto (DEBRIS); 
makednst) PIT, 0, spit); 
make Joe ( debris , 

"You u are u in u a u debris u room u f illed u with u \ 

stuff u washed u in u from u the u surf ace . \n\ 
A u low u wide u passage u with u cobbles u becomes u \ 
plugged u with u mud u and u debris\n\ 
here , u but u an u awkward u canyon u leads u upward u aiLd u west . uu \ 
A u note u on u the u wall\n\ 
say s u \ " MAGIC u WORD u XYZZY\ " . " , 

"You’re u in u debris u room. " , 0); 

makednst (DEPRESSION, not (GRATE, 0), outside); 

makednst (ENTRANCE , 0, inside ) ; 

makednst (CRAWL, 0, cobbles); ditto (COBBLES); ditto(PASSAGE); ditto) LOW); 
ditto (E); 

makednst (CANYON, 0, awk); ditto(IN); ditto) U); ditto) W); 
makednst)^. YZZY, 0, house); 
makednst (PIT , 0, spit); 
make Joe )awk , 

"You u are u in u an u awkward u sloping u east/west u canyon. " ,0,0); 

makednst (DEPRESSION, not (GRATE, 0), outside); 

makednst (ENTRANCE , 0, inside ) ; 

makednst (D,0, debris); ditto (E); ditto (DEBRIS); 

makednst )1N ,0, bird); ditto (U); ditto) W); 

makednst (PIT, 0, spit); 

make Joe ) bird , 

" You u are u in u a u splendid u chamber u thirty u f eet u high . uu \ 
The u walls u are u frozen\n\ 
rivers u of u orange u stone . uu \ 

An u awkward u canyon u and u a u good u passage u exit\n\ 
from u east u and u west u sides u of u the u chamber . " , 
"You’re u in u bird u chamber . " , bird-hint); 
makednst (DEPRESSION, not (GRATE, 0), outside); 
makednst (ENTRANCE, 0, inside); 
makednst (DEBRIS, 0, debris); 
makednst) CANYON, 0, awk); ditto) E); 


CAVE CONNECTIONS 


Adventure 265 


makeJnst (PASSAGE, 0, spit); ditto(PU); ditto (V); 
make Joe (spit , 

" At u your u f eet u is u a u small u pit u breathing u traces u of u \ 
white u mist . uu An u east\n\ 

passage u ends u here u except u f or u a u small u crack u leading u on. " , 
"You’re u at u top u of u small u pit . " , 0); 
makeJnst (DEPRESSION, not (GRATE, 0), outside ); 
makeJnst (ENTRANCE , 0, inside ); 
makeJnst (DEBRIS, 0, debris ); 
makeJnst (PASSAGE , 0, bird)-, ditto (E); 
makeJnst (D, holds (GOLD), neck)-, ditto ( PIT); ditto) STEPS); 
makeJnst (Pi, 0, emist)-, 

/* good thing you weren’t loaded down with GOLD */ 
makeJnst (CRACK, 0, crack); ditto(\t); 


a-wk = 12, §18. 
bird = 13, §18. 
bird-hint = 16, §20. 
CANYON =40, §9. 
cobbles = 10, §18. 
COBBLES =64, §9. 
CRACK =55, §9. 
crack = 129, §18, §59. 
CRAWL =21, §9. 

D = 9, §9. 

DARK =66, §9. 

DEBRIS = 50, §9. 
debris = 11, §18. 
DEPRESSION =32, §9. 
ditto = macro ( ), §21. 
E = 2, §9. 

emist = 15, §18, §32. 
ENTRANCE = 33, §9. 
GOLD = 51, §11. 

GRATE = 3, §11. 
holds = macro ( ), §21. 


house = 3, §18, §25. 

IN = 12, §9. 
inside =9, §18, §30. 
lighted = 1, §20. 

LOW = 67, §9. 

makeJnst = macro ( ), §21. 
make Joe = macro (), §21. 
neck = 130, §18, §60. 
not = macro ( ), §21. 
NOWHERE = 74, §9. 

OUT = 13, §9. 
outside = 8, §18, §29. 
PASSAGE =38, §9. 

PIT = 53, §9. 
spit = 14, §18. 

STEPS = 63, §9. 

SURFACE =65, §9. 

U = 8, §9. 

W = 3, §9. 

XYZZY = 70, §9. 


266 Selected Papers on Fun and Games 

32. Welcome to the main caverns and a deeper level of adventures. 

( Build the travel table 23 ) += 

make Joe (emist , 

"You u are u at u one u end u of u a u vast u hall u \ 

stretchinguf orward u out u of u sight u to\n\ 
the u west . uu There u are u openings u to u either u side , uu \ 

Nearby , u a u wide u stone\n\ 
staircase u leads u downward . uu \ 

The u hall u is u f illed u with u wisps u of u white u mist\n\ 
swaying u to u and u f ro u almost u as u if u alive . uu \ 
A u cold u wind u blows u up u the\n\ 
staircase . uu Thereuis u a u passageu\ 

at u the u top u of u a u dome u behind u you. " , 

"You’re u in u Hall u of u Mists . ", 0); 

makeJnst [L,0, nugget)-, ditto (S); 

mafce_msi (FORWARD, 0, efiss)-, ditto (HALL); ditto ( W); 

makeJnst (STAIRS, 0, hmk)\ ditto) D); ditto( N); 

makeJnst)\J, holds (GOLD), cant); diito(PIT); ditto(STEPS); 

ditto (DOME); ditto (PASSAGE); ditto) E); 

makeJnst) U, 0, spit)-, 

makeJnst (Y2 , 0 , jumble)-, 

33. To the left or south of the misty threshold, you might spot the 
first treasure. 

( Build the travel table 23 ) += 
make Joe ( nugget , 

"Thisuisuaulowuroomuwithuaucrudeunoteuonutheijwall . uu \ 
The u note u says , \n\ 

\"You u Mon’t u get u it u up u the u steps\" . " , 
"You’reuinunuggetuofugolduroom. " , 0); 
makeJnst (HALL, 0, emist)-, ditto(OUT); ditto(N); 

34. Unless you take a circuitous route to the other side of the Hall of 
Mists, via the Hall of the Mountain King, you should make the CRYSTAL 
bridge appear (by getting it into state 1). 

( Build the travel table 23 ) += 
make Joe ( efiss , 

"Youuareuonutheueastubankuof u a u f issure u \ 

slicing u clear u across u the u hall . \n\ 
The u mist u is u quite u thick u here , u \ 

and u the u f issure u is u too u wide u to u jump. " , 
"You’reuon u east u bank u of u f issure . " , 0); 
makeJnst (HALL, 0, emist)-, ditto) E); 
remark ( " I u respectf ully u suggest u you u go u \ 

across u the u bridge u instead u of u jumping. " ); 


CAVE CONNECTIONS 


Adventure 267 


bridge.rmk = sayit-, 

makeAnst) JUMP, not (CRYSTAL, 0), sayit)-, 

makeAnst (FORWARD , not (CRYSTAL , 1), lose)-, 

remarfc("There u is u no u way u across u the u fissure. " ); 

makeAnst [OVER, not (CRYSTAL, 1), sayit); ditto) ACROSS); ditto) W); 

ditto (CROSS); 

makeAnst (OVER, 0, wfiss)-, 

make Joe ( wfiss , 

"You u are u on u the u west u side u ofuthe u f issure u in u the u Hall u of u Mists . " , 

0 , 0 ); 

makeAnst ( JUMP , not ( CRYSTAL , 0) , bridge-rmk ) ; 
makeAnst (FORWARD , not (CRYSTAL, 1), lose)-, 

makeAnst (OVER , no<(CRYSTAL, 1), sayit)-, ditto) ACROSS); ditto) E); 

ditto (CROSS); 

makeAnst (OVER, 0, efiss ); 

makeAnst (N, 0, thru)-, 

makeAnst (W, 0, wmist); 


ACROSS = 17, §9. 
cant = 132, §18, §61. 

CROSS =25, §9. 

CRYSTAL = 14, §11. 

D = 9, §9. 

ditto = macro ( ), §21. 

DOME = 56, §9. 

E = 2, §9. 

efiss = 17, §18, §34. 
emist = 15, §18, §32. 
FORWARD = 14, §9. 

GOLD = 51, §11. 

HALL = 59, §9. 
hmk = 50, §18, §40. 
holds = macro (), §21. 
jumble = 55, §18, §41. 

JUMP =22, §9. 

L = 10, §9. 

lose = 131, §18, §60. 

makeAnst = macro ( ), §21. 


make Joe = macro (), §21. 
N = 0, §9. 

not = macro ( ), §21. 
nugget = 16, §18, §33. 

OUT = 13, §9. 

OVER = 16, §9. 

PASSAGE =38, §9. 

PIT = 53, §9. 

remark = macro ( ), §21. 

S = l, §9. 

sayit = macro, §21. 
spit = 14, §18, §31. 
STAIRS =62, §9. 

STEPS =63, §9. 
thru = 136, §18, §61. 

U = 8, §9. 

W = 3, §9. 

wfiss = 18, §18, §34. 
wmist = 19, §18, §35. 

Y2 =69, §9. 


268 Selected Papers on Fun and Games 

35. What you see here isn’t exactly what you get; N takes you east 
and S sucks you in to an amazing maze. 

( Build the travel table 23 } += 
makedoc ( wmist , 

"You u are u atuthe u westuend u of u the u Hall u of u Mists . uu \ 
A u low u wide u crawl\n\ 

continues u west u and u another u goes u north . uu \ 
To u the u south u is u a u little\n\ 
passage u 6 u f eet u of f u the u f loor . " , 
"You’re u at u west u end u of u Hall u of u Mists . " , 0); 

makednst(S, 0, likel ); ditto( U); ditto ( PASSAGE); ditto (CLIMB); 

makednst (E , 0, wfiss ); 

makednst) N, 0, duck); 

makednst (\l,0, elong); ditto) CRAWL); 

36. The twisty little passages of this maze are said to be all alike, but 
they respond differently to different motions. For example, you can go 
north, east, south, or west from likel , but you can’t go north from like2 . 
In that way you can psych out the whole maze of 14 similar locations. 
(And eventually you will want to know every place where treasure might 
be hidden.) The only exits are to wmist and brink. 

{ Build the travel table 23 ) += 

makeJoc (like 1 , all-alike, 0, twist-hint); 

makednst )V, 0, wmist); makednst (N , 0, likel ); makednst) E, 0, like2); 
makednst(S, 0, like \ ); makednst )W, 0, likel 1 ); 

makedoc(like2 , all-alike, 0, twist-hint); 

makednst (W , 0, likel ); makednst(S, 0, UkeS); makednst) E, 0, like4 ); 
makedoc(like3 , all-alike ,0, twist-hint); 
makednst (E, 0, like2 ) ; makednst (D, 0, dead5 ) ; 
makednst (S, 0, Uke6 ) ; makednst (N, 0, dead9 ) ; 

make Joe (like4 , all-alike , 0, twist-hint); 

makednst (W, 0, likel ) ; makednst (N, 0, like2 ) ; makednst (E, 0, deadS ) ; 

makednst (S, 0, dead4); makednst (U, 0, likely); ditto (D); 

makedoc ( like5 , alLalike , 0, twist-hint ) ; 

makednst (E,0, like6); makednst (W, 0, likel); 

makedoc (like6 , alLalike ,0, twist-hint); 

makednst (E, 0, likeS); makednst (W, 0, Hke5); 

makednst) D,0, likel); makednst(S,0, like8); 

makedoc (likel , alLalike ,0, twist-hint); 
makednst (W,0, Uke5); makednst) U,0, like6); 
makednst(E, 0, like8); makednst(S, 0, like9); 
makedoc (like8 , alLalike, 0, twist-hint); 


CAVE CONNECTIONS 


Adventure 269 


makeAnst) W, 0, like6); makeAnst) E, 0, like 7); makeAnst )S, 0, like8); 
makeAnst) U,0, ZifceP ); make-inst( N,0, likelO); makeAnst) D,0, dead!! ); 
makeAoc )like9 , alLalike, 0, twist.. hint ) ; 

makeAnst) W, 0, ZifeeT); makeAnst) N, 0, like8 ); makeAnst) S,0, dead6); 

make Aoc)likel0 , alLalike , 0, twist-hint ); 

makeJnstlM, 0, makeAnst) N, 0, likelO); 

makeAnst )D, 0, dead7); makeAnst (E, 0, brink)-, 

make Joe (like 11 , alLalike, 0, twist-hint); 

makeAnst )N,0Jikel ); makeAnst )V,0, likel 1); ditto) S); 

makeAnst (E,0, tZeadi ); 

makeJoc(likel2 , alLalike , 0, twist-hint); 

makeAnst (S , 0, 6rmA: ) ; makeAnst (E, 0, iifceZ 3 ) ; makeAnst (W, 0, deadl 0 ) ; 
makeAoc (like 1 3 , alLalike ,0, twist-hint); 
makeAnst (N, 0, 6rmA:); makeAnst (W, 0, likel 2); 
makeAnst (NW, 0, dead2); /* NW: a dirty trick! */ 

makeAoc (like 14 , alLalike, 0, twist-hint); 
makeAnst (U, 0, like4 ) ; ditto (D) ; 


alLalike: char [], §21. 
brink = 34, §18, §37. 
CLIMB = 23, §9. 

CRAWL =21, §9. 

D = 9, §9. 

deadl = 107, §18, §56. 
dead2 = 108, §18, §56. 
dead3 = 109, §18, §56. 
dead4 = 110, §18, §56. 
dead5 = 111, §18, §56. 
dead6 = 112, §18, §56. 
deadl = 113, §18, §56. 
dead9 = 115, §18, §56. 
deadlO = 116, §18, §56. 
deadll = 117, §18, §56. 
ditto = macro ( ), §21. 
duck = 137, §18, §61. 

E = 2, §9. 

elong = 35, §18, §38. 
likel =20, §18, §36. 
likeS =21, §18. 

Iike3 =22, §18. 


hfce^ =23, §18, §36. 

Hke5 = 24, §18. 

Iike6 = 25, §18, §36. 
like 7 = 26, §18. 

Iike8 =27, §18. 

Iike9 =28, §18. 
likelO =29, §18. 

Zifcell =30, §18. 

Iikel2 = 31, §18. 
likel 3 = 32, §18. 

K*el^ =33, §18. 
makeAnst = macro (), §21. 
makeAoc = macro (), §21. 
N = 0, §9. 

NW = 6, §9. 

PASSAGE = 38, §9. 

S = 1, §9. 

twist-hint = 64, §20. 

U = 8, §9. 

W = 3, §9. 

ui/jss = 18, §18, §34. 
wmist = 19, §18, §35. 


270 Selected Papers on Fun and Games 

37. ( Build the travel table 23 ) += 

make Joe (brink, 

"You u are u on u the u brink u of u a u thirty-f oot u pit u \ 
with. u a u massive u orange u column\n\ 
down u one u wall . uu You u could u climb u down u here u \ 
but u you u could u not u get u back\n\ 
up . uuThe u maze u continues u at u this u level . " , 
"You’re u at u brink u of u pit . " , 0); 
makeJnst( D, 0, bird); ditto) CLIMB); 
makeJnst )V, 0, likelO ); makeJnst) S, 0, dead8); 
makeJnst)N,0, Ukel2); makeJnst(E,0, UkelS ); 

38. Crawling west from wmist instead of south, you encounter this. 
{ Build the travel table 23 ) += 

make Joe ( elong , 

"YouuareuatutheueastuenduofuauveryulonguhalluX 
apparent ly u without u side\n\ 

chambers . uuToutheueastuauloWuWideucrawluslantSuup . uu \ 
To u the u north u a\n\ 
round u two-f oot u hole u slants u down. " , 
"You’re u at u east u end u ofulong u hall . " , 0); 

makeJnst(E, 0, wmist); ditto) U); ditto) CRAWL); 
makeJnst) W, 0, wlong); 

makeJnst)H,0, cross); ditto)D); ditto (HOLE); 
makeJoc)wlong , 

"You u are u at u the u west u end u of u a u very u long u \ 
f eatureless u hall . uu The u hall\n\ 
joins u up u with u a u narrow u north/ south u passage . " , 
"You’re u at u west u end u of u long u hall . " , 0); 

makeJnst) E, 0, elong); 
makeJnst) N, 0, cross); 
makeJnst) S, 100, diffO); 


CAVE CONNECTIONS 


Adventure 


271 


bird = 13, §18, §31. 
brink = 34, §18. 

CLIMB =23, §9. 

CRAWL = 21, §9. 

cross =49, §18, §40. 

D = 9, §9. 

dead8 = 114, §18, §56. 
diffO =37, §18, §39. 
ditto = macro ( ), §21. 
E = 2, §9. 
elong = 35, §18. 

HOLE = 57, §9. 


likelO = 29, §18, §36. 
like 12 =31, §18, §36. 
Iikel3= 32, §18, §36. 
makeAnst = macro (), §21. 
makeJoc = macro ( ), §21. 
N = 0, §9. 

S = l, §9. 

U = 8, §9. 

W = 3, §9. 
i along = 36, §18. 
wmist = 19, §18, §35. 


272 Selected Papers on Fun and Games 

39. Recall that the code ‘100’ on the last instruction above means, 
“Dwarves not permitted.” It keeps them out of the following maze, 
which is based on an 11 x 11 latin square. (Each of the eleven locations 
leads to each of the others under the ten motions N, S, E, W, NE, SE, NW, 
SW, U, D — except that diffO goes down to the entrance location wlong 
instead of to diffl 0 , and diffl 0 goes south to the dead-end location pony 
instead of to diffO . Furthermore, each location is accessible from all ten 
possible directions.) 

Incidentally, if you ever get into a “little twisting maze of passages,” 
you’re really lost. 

^define twist (l,n, s, e,w, ne, se, nw , sw , u, d, m) 
make Joe (l, m, 0, 0); 

makeJnst (N, 0, n); makeJnst (S, 0, s); makeJnst (E, 0, e); 
makeJnst (V , 0, u>); 

makeJnst (NE, 0, ne); makeJnst (SE, 0, se); makeJnst(Wd ,0, nw); 

makeJnst(S\l, 0, sw); 

makeJnst( U, 0, u)\ makeJnst(T), 0, d); 

( Build the travel table 23 ) += 

twist ( diffO , diff9 , diffl , diff 7 , diff8 , diffS , diff 4 , diff6 , diff2 , diff5 , wlong , 
"You u are u in u a u maze u of u twisty u littleupassages , u all u dlff erent . " ); 
twist ( diffl , diff 8 , diff 9 , diffl 0 , diffO , diff 5 , diff 2 , diff 3 , diff 4 , diff 6 , diffl , 
"You u are u in u a u maze u of u twisting u little u passages , u all u diff erent . " ) 
twist ( diff 2 , diff 3 , diff 4 , diff 8 , diff 5 , diffl , diffl 0 , diffO , diff 6 , diffl , diff 9 , 
"You u areuin u a u little u maze u of u twisty u passages , u all u diff erent . " ); 
twist ( diffS , diffl , diffl 0 , diff 6 , diff 2 , diff 4 , diff 9 , diff 8 , diff 5 , diffO , diffl , 
"You u are u in u a u twisting u maze u of u little u passages , u all u diff erent . " ) 
twist ( diff 4 , diffl , diffl , diff 5 , diff 9 , diffO , , dijp , di/fl 0 , diff 8 , diff 6 , 

"You u are u in u a u twisting u little u maze u of u passages , u all u diff erent . " ) 
twist ( diff 5 , diffO , diffS , dijgff , , diff 8 , , diff 9 , diif7 , dijffl 0 , , 

" You u are u in u autwisty u little u maze u of u passages , u all u diff erent . " ); 
twist (diff 6 , dijffl 0 , diff 5 , *#0 , diffl , diff 9 , diff 8 , diff 7 , diffl? , diff2 , dij% , 
"You u are u in u a u twisty u maze u of u little u passages , u all u diff erent . " ); 
twist ( diffl , diff 6 , diff2 , diff 9 , diffl 0 , diffl , diffO , diff5 , diff 8 , diff 4 , diff? , 
"You u are u in u a u little u twisty u niaze u of u passages , u all u diff erent . " ); 
twist ( diff 8 , diff5 , diff 6 , diffl , diff^ , diff2 , diff7 , dzffl 0 , diff 9 , diff 3 , diffO , 
"You u are u in u a u maze u of u little u twisting u passages >u all u diff erent . " ) 
twist ( diff? , diff 4 , diff 8 , diffS , diff? , diffl 0 , diff? , diffl , diff? , diff7 , diff 5 , 
"You u are u in u a u maze u of u little u twi st y u pas sages >u all u diff erent . " ); 
twist ( diffl 0 , diffS , pony , diffS , diff7 , diff? , diff 5 , diff^ , diffl , diff? , diff 8 , 
"You u are u in u a u little u maze u of u twisting u passages , u all u diff erent . " ) 

make Joe (pony , dead-end, 0, 0); 
makeJnst (N, 0, diff 10); ditto ( OUT); 


CAVE CONNECTIONS 


Adventure 273 


D = 9, §9. 

dead-end : char [], §21. 
diffO= 37, §18. 
diffl =38, §18. 
diff2 =39, §18. 
diff 3 =40, §18. 
diff 4 =41, §18. 
diff 5 = 42, §18. 
diff 6 = 43, §18. 
diff 7 = 44, §18. 
diff8 =45, §18. 
diff9 =46, §18. 
diff 10 =47, §18. 

<i«Mo = macro ( ), §21. 


E = 2, §9. 

make-inst = macro (), §21. 
make Joe = macro (), §21. 
N = 0, §9. 

NE = 4, §9. 

NW = 6, §9. 

OUT = 13, §9. 
pony = 48, §18. 

S = 1, §9. 

SE = 5, §9. 

SW = 7, §9. 

U = 8, §9. 

W = 3, §9. 

wlong = 36, §18, §38. 


274 Selected Papers on Fun and Games 

40. Going north from the long hall, we come to the vicinity of another 
large room, with royal treasures nearby. (You probably first reached this 
part of the cavern from the east, via the Hall of Mists.) Unfortunately, 
a vicious snake is here too; the conditional instructions for getting past 
the snake are worthy of study. 

( Build the travel table 23 ) += 
make Joe (cross , 

" You u are u at u a u cros sover u of u a u high u N/S u pas sage u and u a u low u E/W u one . 

0,0); 

makeJnst (W, 0, elong ) ; 
makeJnst) N, 0, deadO ); 
makeJnst)E, 0, west); 
makeJnst(S, 0, wlong); 
make Joe (hmk , 

"You u are u in u the u Hall u of u the u Mountain u King, u \ 
with u passages u of f u in u all\n\ 
directions . " , 

"You’re u in u Hall u of u Mt u King. " , snake-hint); 

makeJnst (STAIRS, 0, emist); ditto (U); ditto (E); 

makeJnst (N, not (SNAKE , 0) , ns ) ; ditto (L) ; 

makeJnst (S, not (SNAKE, 0), south); ditto (R); 

makeJnst ( W, not (SNAKE , 0) , west ) ; ditto (FORWARD ) ; 

makeJnst (N, 0, snaked); 

makeJnst)SV , 35, secret); 

makeJnst)SW , sees(SNAKE), snaked); 

makeJnst (SECRET, 0, secret); 

makeJoc(west, 

"You u are u in u the u west u side u chamber u of u the u \ 

Hall u of u the u Mountain u King . \n\ 
A u passage u continues u west u and u up u here . " , 
"You'reuinuwestusideuChamber . " , 0); 

makeJnst)EALL,0, hmk); ditto) OUT); ditto (E); 
make Jnst)V,0, cross); ditto) U); 
makeJoc)south, 

"You u are u in u the u south u side u chamber .",0,0); 
make Jnst )HALL , 0, hmk); ditto) OUT); ditto) N); 


CAVE CONNECTIONS 


Adventure 


275 


cross = 49, §18. 
deadO = 106, §18, §56. 
ditto = macro ( ), §21. 

E = 2, §9. 

elong= 35, §18, §38. 
emist = 15, §18, §32. 
FORWARD = 14, §9. 

HALL = 59, §9. 
hmk = 50, §18. 

L = 10, §9. 

make-inst = macro (), §21. 
make Joe = macro (), §21. 
N = 0, §9. 

not = macro ( ), §21. 
ns = 53, §18, §41. 

OUT = 13, §9. 


R= 11, §9. 

S = 1, §9. 

SECRET =42, §9. 
secret = 99, §18, §53. 
sees = macro ( ), §21. 
SNAKE = 13, §11. 
snake-hint = 32, §20. 
snaked = 135, §18, §61. 
south = 52, §18. 
STAIRS =62, §9. 

SW = 7, §9. 

U = 8, §9. 

W = 3, §9. 
west = 51, §18. 
i along = 36, §18, §38. 


276 Selected Papers on Fun and Games 

41. North of the mountain king’s domain is a curious shuttle station 
called Y2, with magic connections to two other places. 

(Crowther led a team in 1974 that explored region “Y” of Colossal 
Cave; “Y2” was the second location to be named in this region.) 

{ Build the travel table 23 ) += 
make Joe )ns , 

"YoUuare u inuauloWuN/Supassage u at u a u holeuinuthe u f loor , U u\ 
The u hole u goes\n\ 
down u to u an u E/W u passage . " , 

"You’re u in u N/S u passage . " , 0); 
make-inst (HALL, 0, hmk); ditto) OUT); ditto( S); 
makeAnst (N, 0, y2); ditto (Y2); 
makeAnst) D,0, dirty); ditto) HOLE); 

makeJoc)y2 , 

"You u are u inuaularge u room, u with u a u passage u tOuthe u south , u \ 
a u passage u to u the\n\ 

west , u and u a u wall|jof u broken u rock u to u the u east . U u\ 
There u is u a u large u \ " Y2\ " u on\n\ 
a u rock u in u the u room ’ s u center . " , 

"You’re u at u \"Y2\" . " ,0); 
makeAnst (PLUGH, 0, house); 
makeAnst(S,0, ns); 

makeAnst (E, 0, jumble); ditto) WALL); ditto (BROKEN); 
makeAnst (W , 0, windoe); 
makeAnst (PLOVER . holds (EMERALD ) , pdrop ) ; 
makeAnst (PLOVER, 0, proom); 

make Joe )jumble , 

"You u areuin u aujumble u of u rock, u with u cracks u everywhere . " ,0,0); 
makeAnst)D,0, y2); ditto) Y2); 
makeAnst (U, 0, emist ) ; 

make Joe )windoe , 

"You’re u at u a u low u window u overlooking u a u huge u pit , u \ 
which u extends u up u out u of \n\ 
sight . uu A u f loor u is u indistinctly u visible u \ 
over u 50 u f eet u below . uu Traces u of \n\ 
white u mist u cover u the u f loor u of u the u pit , u \ 
becoming u thicker u to u the u right . \n\ 
MarkSuin u the u dust u around u the u window u \ 
would u seem u to u indicate u that\n\ 
someone u has u been u here u recently . uu \ 

Direct ly u across u the u pit u from u you u and\n\ 

25 u f eet u away u there u is u a u similar u window u \ 
looking u into u a u lighted u room. \n\ 


CAVE CONNECTIONS 


Adventure 


277 


A u shadowy u f igure u canube u seen u there u \ 
peering u back u at u you. " , 
"You’reuatuwindowuoiiupit . " , 0); 

make.inst (E,0, y2); ditto (Y2); 
make-inst( JUMP, 0, neck); 


BROKEN = 49, §9. 

D = 9, §9. 

dirty = 57, §18, §42. 
ditto = macro ( ), §21. 

E = 2, §9. 

EMERALD =60, §11. 
emist = 15, §18, §32. 

HALL = 59, §9. 
hmk = 50, §18, §40. 
holds = macro (), §21. 
HOLE = 57, §9. 
house =3, §18, §25. 
jumble = 55, §18. 

JUMP = 22, §9. 
makeSnst = macro (), §21. 
makeJoc = macro ( ), §21. 


N = 0, §9. 

neck = 130, §18, §60. 
ns = 53, §18. 

OUT = 13, §9. 
pdrop = 142, §18, §146. 
PLOVER = 72, §9. 
PLUGH = 71, §9. 
proom = 90, §18, §51. 

S = 1, §9. 

U = 8, §9. 

W = 3, §9. 

WALL = 58, §9. 
windoe = 56, §18. 

Y2 =69, §9. 

2/2 = 54, §18. 


278 Selected Papers on Fun and Games 

42. Next let’s consider the east/west passage below ns. 

( Build the travel table 23 ) += 
make Joe (dirty , 

"Youuareuinuaudirtyubrokenupassage . uu \ 

To u the u east u is u a u crawl . uu To u the\n\ 
west u is u a u large u passage . uu \ 

Above u you u is u a u hole u to u another u passage . " , 
"You’re u in u dirty u passage . " , 0); 
make.inst{ E,0, clean); ditto {CRAWL); 
makeJnst)\i,0,ns); ditto) HOLE); 
makeJnst) W, 0, dusty); 
makeJnst (BEDQUILT, 0, bedquilt); 

make Joe {clean, 

"You u are u onutheijbrink u of u a u small u cleanuClimbable u pit . uu \ 
A u crawl u leads\n\ 
west . " , 

"You’re u by u a u clean u pit . " , 0); 

makeJnst { W,0, dirty); ditto ( CRAWL); 
makeJnst (D, 0, wet); ditto) PIT); ditto) CLIMB); 

make Joe {wet , 

"You u are u in u the u bottom u of u a u small u pit u \ 
with u a u little u stream, u which\n\ 
enters u and u exits u through u tiny u slits . " , 
"You’re u in u pit u by u stream. " , liquid); 
makeJnst (CLIMB, 0, clean); ditto (U); ditto (OUT); 

makeJnst (SLIT, 0, slit.rmk); ditto (STREAM); ditto) D); ditto (UPSTREAM ) : 
ditto (DOWNSTREAM ); 

make Joe {dusty , 

"You u are u in u aularge u roomuf ull u of u dusty u rocks . uu \ 
ThereuisuaubiguholeuinXnS 
the u f loor . uu There u are u cracks u everywhere , u \ 
and u a u passage u leading u east . " , 
"You’re u in u dusty u rock u room. " ,0); 
makeJnst) E, 0, dirty); ditto) PASSAGE); 
makeJnst)D,0, complex); ditto(HOLE); ditto) FLOOR); 
makeJnst (BEDQUILT, 0, bedquilt); 

make Joe ( complex , 

"You u are u at u a u complex u junction. uu \ 

A u low u hands-and-knees u passage u from u the\n\ 
north u joins u a u higher u crawl u f rom u the u east u \ 
to u make u a u walking u passage\n\ 
going u west . uu There u is u also u a u large u room u above . ULJ \ 
The u air u is u damp u here . " , 


CAVE CONNECTIONS 


Adventure 


279 


"You’re u at u complex u jmiction. " , 0); 

make.inst(V,0, dusty); ditto( CLIMB); ditfo(ROOM); 
makeJnst (W, 0, bedquilt ) ; ditto (BEDQUILT ) ; 
makeJnst (U,0, shell)-, ditto ( SHELL); 
makeJnst) E, 0, ante); 


ante = 66, §18, §44. 
BEDQUILT =43, §9. 
bedquilt =68, §18, §45. 
clean = 58, §18. 

CLIMB = 23, §9. 
complex = 61, §18. 

CRAWL = 21, §9. 

D = 9, §9. 
dirty = 57, §18. 
ditto = macro ( ), §21. 
DOWNSTREAM = 19, §9. 
dusty = 60, §18. 

E = 2, §9. 

FLOOR = 61, §9. 

HOLE = 57, §9. 
liquid = 4, §20. 
makeJnst = macro ( ), §21. 


make Joe = macro (), §21. 

N = 0, §9. 

ns = 53, §18, §41. 

OUT = 13, §9. 

PASSAGE = 38, §9. 

PIT = 53, §9. 

ROOM = 60, §9. 

SHELL = 47, §9. 
shell = 62, §18, §43. 

SLIT = 54, §9. 
slit-rmk: int, §28. 

STREAM = 31, §9. 

U = 8, §9. 

UPSTREAM = 18, §9. 

W = 3, §9. 
wet = 59, §18. 


280 


Selected Papers on Fun and Games 

43. A more-or-less self-contained cavelet can be found north of the 
complex passage. Its connections are more vertical than horizontal. 

{ Build the travel table 23 ) += 
make-loc (shell , 

" You ’ re u in u a u large u r oom u carved u out u of u \ 
sedimentary u rock . U uThe u f loor\n\ 
and u walls u are u littered u with u bits u of u shells u \ 
embedded u in u the u stone . \n\ 
A u shallow u passage u proceeds u downward, u \ 
cmd u a u somewhat u steeper u one\n\ 
leads u up . uu A u low u hands-and-knees u passage u \ 
enters u from u the u south. " , 

"You’reuiiiuShelluRoom. " , 0); 
makeJnst (U, 0, arch ) ; ditto ( HALL ) ; 
makeJnst) D, 0, ragged); 

remark ("You u can’ t u f it u this u f ive-f oot u clam u \ 
through u that u little u passage ! " ); 

makeJnst) S, holds (CLAM), sayit ); 

remark ("You u can ’ t u f it u this u f ive-f oot u oyster u \ 
through u that u little u passage ! " ); 

makeJnst) S, holds (OYSTER), sayit); 
makeJnst)S, 0, complex); 
make Joe (arch, 

"You u are u in u an u arched u hall . uu A u coral u passage u \ 
once u cont inued u up u and u east \n \ 
from u here , u but u is u now u blocked u by u debris . uu \ 

The u air u smells u of u sea u water . " , 

"You’re u in u arched u hall. " ,0); 

makeJnst (D, 0, shell); dirto(SHELL); ditto(0XS1); 

make Joe ( ragged , 

"You u are u in u a u long u sloping u corridor u with u ragged u sharp u walls . " , 

0,0); 

makeJnst (U , 0, shell); ditto) SHELL); 
makeJnst( D, 0, sac); 
make Joe (sac, 

"You u are u in u a u cul-de-sac u about u eight u f eet u across . " , 0, 0); 

makeJnst (U, 0, ragged); ditto) OUT); 
makeJnst (SHELL, 0, shell); 

44. A dangerous section lies east of the complex junction. 

( Build the travel table 23 ) += 

make Joe (ante , 

"You u are u in u an u anteroom u leading u to u \ 

a u large u passage u to u the u east . uu Sraall\n\ 


CAVE CONNECTIONS 


Adventure 281 


passages u go u west u and u up . uu \ 

TheuremnantSuOfurecentudigginguareuevident . \n\ 
A u sign u in u midair u here u says u \ 

\"CAVE u UNDER u CONSTRUCTION u BEYOND u THIS u POINT. \n\ 
PROCEED u AT u OWN u RISK . uu [WITT u CONSTRUCTION u COMPANY] \ , 
"You’re u in u anteroom. " , 0); 
makeJnst(V, 0, complex ); 
makeJnst) W, 0 , bedquilt); 
makeJnst) E, 0 , witt); 
make Joe {witt , 

" You u are u at u Witt ’ s u End . uu \ 

Passages u lead u off u inu\ "all V'udirect ions • " , 

"You’re u at u Witt ’ s u End. " , witt-hint); 
remarfc ("You u have u crawled u arounduin u some u little u holes u \ 
and u wound u up u back u in u the \n \ 
main u passage . " 

loop-rmk = sayit; 

makeJnst(E,95, sayit); ditto (N); ditto (S); 
ditto ( NE); ditto( SE); ditto( SW); ditto { NW); ditto ( U); ditto ( D); 
make.inst (E, 0 , ante)-, /* one chance in 20 */ 
remark ("You u haveuCrawled u around u in u some u little u holes u \ 
and u f ound u y our u way \n \ 
blocked u by u a u recentucave-in. uu \ 

You u are u now u back u in u the u main u passage . " 
makeAnst( W, 0 , sayit); 


ante = 66, §18. 
arch = 63, §18. 
bedquilt = 68, §18, §45. 
CLAM = 17, §11. 
complex = 61, §18, §42. 

D = 9, §9. 

ditto = macro ( ), §21. 

E = 2, §9. 

HALL =59, §9. 
holds = macro ( ), §21. 
makeAnst = macro (), §21. 
make Joe = macro (), §21. 
N = 0, §9. 

NE = 4, §9. 

NW = 6, §9. 


OUT = 13, §9. 

OYSTER = 18, §11. 
ragged = 64, §18. 
remart = macro (), §21. 
S = 1, §9. 
sac = 65, §18. 
sayit = macro, §21. 

SE = 5, §9. 
shell = 62, §18. 

SHELL =47, §9. 

SW = 7, §9. 

U = 8, §9. 

W = 3, §9. 
witt = 67, §18. 
witt-hint = 256, §20. 


282 Selected Papers on Fun and Games 

45. Will Crowther, who actively explored and mapped many caves 
in Kentucky before inventing Adventure, named Bedquilt after the 
Bedquilt Entrance to Colossal Cave. (The real Colossal Cave was dis- 
covered near Mammoth Cave in 1895, and its Bedquilt Entrance was 
found in 1896; see The Longest Cave by Brucker and Watson (New 
York: Knopf, 1976) for further details.) 

Random exploration is the name of the game here. 

( Build the travel table 23 ) += 
make Joe ( bedquilt , 

"You u are u in u Bedquilt , u \ 

a u long u east/west u passage u with u holes u everywhere . \n\ 
TouexploreuaturandomuSelectunorthjuSouth.uupjuOrudown. " , 
"You’re u in u Bedquilt . " , 0); 

makeJnst( E, 0, complex); 
makeJnst( W, 0, cheese); 
makeJnst (S, 80, loop^rmk); 
makeJnst (SLAB , 0, slab ) ; 
makeJnst (U, 80, loop.rmk); 
make Justly, 50, abovep); 
makeJnst (U, 0, dusty); 
makeJnst (N, 60, loop-rmk); 
makeJnst(N, 75, low); 
makeJnst (N, 0, sjunc); 
makeJnst(D, 80, loop_rmk); 
makeJnst (D, 0, ante); 

make Joe ( cheese , 

"Youuare u in u a u room u whose u walls u resembleuSwisSucheese . uu \ 
0bvious u passages\n\ 
gouwest , u east , U NE , u and u NW . U u\ 

Part u of u the u room u is u occupied u by u a u large\n\ 
bedrock u block. 11 , 

"You’re u in u Swiss u cheese u room. " , 0); 
makeJnst (NE, 0, bedquilt); 
makeJnst (W , 0 , e2pit ) ; 
makeJnst) S,80, loop.rmk); 
makeJnst (CANYON, 0, tall); 
makeJnst (E, 0, soft); 
makeJnst (NW , 50, loop-rmk); 
makeJnst (ORIENTAL, 0, oriental); 

make Joe (soft , 

"You u are u in u the u Sof t u Room. uu \ 

The u wallS|jare u covered u with u heavy u curtains , \n\ 


CAVE CONNECTIONS 


Adventure 


283 


the u f loor u with u a u thick u pile u carpet . uu \ 
Moss u covers u the u ceiling. " , 
"You’re u in u Soft u Room. " , 0); 

makeJnst(\l, 0, cheese ); ditto( OUT); 


abovep = 81, §18, §48. 
ante = 66, §18, §44. 
bedquilt =68, §18. 

CANYON = 40, §9. 
cheese = 69, §18. 
complex = 61, §18, §42. 

D = 9, §9. 

ditto = macro (), §21. 
dusty =60, §18, §42. 

E = 2, §9. 

eSpit = 71, §18, §46. 
loop^rmk : int, §44. 
low = 84, §18, §48. 
makejnst = macro ( ), §21. 
make Joe = macro ( ), §21. 


N = 0, §9. 

NE = 4, §9. 

NW = 6, §9. 

ORIENTAL = 46, §9. 
oriental = 87, §18, §50. 
OUT = 13, §9. 

S = l, §9. 

sjunc = 82, §18, §48. 
SLAB =36, §9. 
slab =92, §18, §52. 
soft = 70, §18. 
tall = 102, §18, §54. 

U = 8, §9. 

W = 3, §9. 


284 


Selected Papers on Fun and Games 

46. West of the quilt and the cheese is a room with two pits. 

Why would you want to descend into the pits? Keep playing and 
you’ll find out. 

( Build the travel table 23 ) += 
make Joe ( e2pit , 

"You u are u at u the u east u end u of u the u Twopit u Room. uu \ 

The u f loor u here u is\n\ 
littered u with u thin u rock u slabs )U \ 

whichumakeuitueasyutoudescendutheupits . \n\ 
ThereuiSuaupathuhereubypassingutheupitSuX 
to u connect u passages u f rom u east\n\ 
anduwest . uu There u are u holes u all u over , u \ 
but u the u only u big u one u is u on u the\n\ 
wall u directly u over u the u west u pit u where u you u caii’t u get u to u it . " , 
"You’reuat u east u end u of u Twopit u Room. " , 0); 
makednst) E, 0, cheese)', 
makednst( W, 0, w2pit); ditto (ACROSS); 
makednst )D, 0, epit); diifo(PIT); 
makeJoc(w2pit, 

"You u are u at u the u west u end u of u the u Twopit u Room. uu \ 
There u is u a u large u hole u in\n\ 
theuwalluaboveutheupituatuthisuenduof u the u room. " , 
"You’re u at u west u end u of u Twopit u Room. " , 0); 

makednst) E, 0, e2pit ); ditto (ACROSS); 
makednst (W, 0, slab ) ; ditto (SLAB ) ; 
makednst(D,0, wpit); ditto(PIT); 
remarfc("It u is u too u far u up u for u you u to u reach. " ); 
makednst (HOLE , 0, sayit ) ; 

makedoc(epit , 

"You u are u at u the u bottom u of u the u eastern u pit u \ 
in u the u Twopit u Room. uu There u is\n\ 
ausmallupooluof u oil u in u one u corner u of u the u pit . " , 
"You’re u in u east u pit . " , liquid + oil)', 
makednst (U, 0, e2pit ) ; ditto (OUT ) ; 
makedoc(wpit, 

"You u are u at u the u bottom u of u the u western u pit u \ 
in u the u Twopit u Room. uu There u is\n\ 
a u large u hole u in u the u wall u about u 25 u feet u above u you. " , 
"You’re u in u westupit . " , 0); 

makednst) U, 0, w2pit)~, ditto (OUT); 
makednst (CLIMB, not (PLANT, 4), check); 
makednst (CLIMB, 0, climb); 


CAVE CONNECTIONS 


Adventure 


285 


ACROSS = 17, §9. 
check = 134, §18, §61. 
cheese =69, §18, §45. 
CLIMB = 23, §9. 
climb = 133, §18, §61. 

D = 9, §9. 

ditto = macro (), §21. 

E = 2, §9. 
e2pit = 71, §18. 
epit = 73, §18. 

HOLE = 57, §9. 
liquid = 4, §20. 
makejnst = macro (), §21. 
make-loc = macro (), §21. 


not = macro (), §21. 
oil = 2, §20. 

OUT = 13, §9. 

PIT = 53, §9. 

PLANT = 28, §11. 
remark = macro ( ), §21. 
sayit = macro, §21. 

SLAB =36, §9. 
slab = 92, §18, §52. 

U = 8, §9. 

W = 3, §9. 
w2pit = 72, §18. 
w pit = 74, §18. 


286 Selected Papers on Fun and Games 

47. Oho, you climbed the plant in the west pit! Now you’re in another 
scenic area with rare treasures — if you can get through the door. 

( Build the travel table 23 ) += 
make Joe (narrow , 

" You u are u in u a u long , u narrow u corr idor u \ 

stretching u out u of u sight u to u the\n\ 
west . uuAt u the u eastern u end u is u \ 

a u hole u through u which u you u can u see u a\n\ 
profusion u of u leaves . " , 

"You’reuinunarrowucorridor . " , 0); 
makeJnst(D,0, wpit); ditto( CLIMB); ditto) E); 
makeJnst ( JUMP, 0, neck); 
makeJnst(M , 0, giant); ditto (GIANT); 

make Joe (giant , 

"You u are u in u the u Giant u Room. ULJ \ 

TheuCeiling u here u is u too u highuupufor u your\n\ 
lamp u to u show u it . uu Cavernous u passages u lead u \ 
east , u north , u and u south . UL1 0n\n\ 
the u west u wall u is u scrawled u the u inscription, u \ 
\"FEE u FIEuF0E u F00\" u [sic] . " , 

"You’re u inuGiant u Room. ", 0); 
makeJnst) S,0, narrow); 
makeJnst( E, 0, block); 
makeJnst) N,0, immense); 

make Joe (block, 

"Theupassageuhereuisublockedubyuaurecentucave-in. " ,0,0); 
make Jnst(S,0, giant); ditto(G IANT); ditto( OUT); 

make Joe (immense, 

"You u are u at u one u end u of u an u iniinenseunorth/south u passage. " ,0,0); 
make Jnst(S,0, giant); ditto) GIANT); ditto (PASSAGE); 
makeJnst)^, not (DOOR, 0), falls); ditto (ENTER); ditto (CAVERN); 
remorfc("The u door u is u extremely u rusty u cind u refuses u to u open. " ); 
makeJnst) N, 0, sayit); 

make Joe (falls , 

"You u are u in u a u magnif icent u cavern u with u a u rushing u stream, u \ 
which u cascades\n\ 

over u a u sparkling u waterf all u into u a u roaring u whirlpool u \ 
that u disappears\n\ 
throughuauholeuinutheuf loor . uu \ 

Passages u exit u to u the u south u cind u west . " , 
"You’re u in u cavern u with u waterfall. " , liquid ); 
makeJnst(S, 0, immense); ditto(OUT); 
makeJnst (GIANT, 0, giant); 


CAVE CONNECTIONS 


Adventure 287 


makeJnst) W, 0, steep)-, 
make Joe ( steep , 

"You u are u at|jthe u top u of u a u steep u incline u \ 
above u a u large u room . uu You u could\n\ 
climb u down u here , u butuyou u would u not u beu\ 
able u to u climb u up. uu There u is u a\n\ 
passage u leading u back u to u the u north. " , 
"You’re u at u steep u incline u above u large u room. " , 0); 
makeJnst (N, 0, falls); ditto (CAVERN); ditto (PASSAGE); 
makeJnst) D, 0, low)\ ditto (CLIMB ); 


block = 77, §18. 
CAVERN = 39, §9. 
CLIMB =23, §9. 

D = 9, §9. 

ditto = macro (), §21. 
DOOR = 11, §11. 

E = 2, §9. 

ENTER = 20, §9. 
falls = 79, §18. 

GIANT =45, §9. 
giant = 76, §18. 
immense = 78, §18. 
JUMP = 22, §9. 
liquid = 4, §20. 
low =84, §18, §48. 


makeJnst — macro (), §21. 
make Joe = macro (), §21. 
N = 0, §9. 
narrow = 75, §18. 
neck = 130, §18, §60. 
not = macro (), §21. 

OUT = 13, §9. 

PASSAGE = 38, §9. 
remark = macro (), §21. 

S = l, §9. 

sayit = macro, §21. 
steep = 80, §18. 

W = 3, §9. 

wpit = 74, §18, §46. 


288 Selected Papers on Fun and Games 

48. Meanwhile let’s backtrack to another part of the cave possibly 
reachable from Bedquilt. 

( Build the travel table 23 ) += 
make Joe ( abovep , 

"YoUuareuin u auSecretuN/S u canyon u above u a u sizable u passage . " , 0, 0); 

makeJnst ( N, 0, sjunc); 

make Jnst (D,0, bedquilt)-, ditto (PASSAGE); 

makeJnst) S, 0, tite); 

make Joe (sjunc, 

"You u are u in u a u secret u canyon u at u \ 

a u junction u of u three u canyons , u bearing\n\ 
north , u south , u and u SE . uu \ 

The u north u one u is u aSutall u as u the u other u two\n\ 
combined. " , 

"You’re u at u junction u of u three u secret u canyons . " , 0); 

makeJnst (SE , 0, bedquilt ) ; 
makeJnst (S, 0, abovep ); 
makeJnst (N, 0, window); 

makeJoc(tite , 

"A u large u stalactite u extends u from u the u roof u \ 
and u almost u reaches u the u f loor\n\ 
below . uu You u could u climb u down u it , u \ 

and u jump u from u it u to u the u f loor , u but\n\ 
having u done u so u you u would u be u \ 

unable u to u reachuit u tOuclimb u back u up . " , 
"You’re u on u top u of u stalactite . " , 0); 
makeJnst (N, 0, abovep); 

makeJnst (D, 40, like6); ditto) JUMP); ditto(CLIMB); 
makeJnst (D, 50, Hke9 ) ; 
makeJnst (D, 0, like4 ); 

/* oh dear, you’re in a random part of the maze */ 
make Joe (low , 

" You u are u in u a u large u low u room . U uCrawls u lead u north >u SE , u and u SW . " , 

0,0); 

makeJnst (BEDQUILT, 0, bedquilt); 
makeJnst (SW ,0, scorr); 
makeJnst) N,0, crawl); 

makeJnst (SE, 0, oriental); ditto (ORIENTAL); 

make Joe (crawl , 

"Dead u end u crawl . " , 0, 0); 

makeJnst (S, 0, low); ditto (CRAWL); ditto) OUT); 


CAVE CONNECTIONS 


Adventure 289 


49. The described view from the west window, window, is identical to 
the view from the east window, windoe , except for one word. What on 
earth do you see from those windows? (Don Woods has confided that 
the shadowy figure is actually your own reflection, because mirror lies 
between the two window rooms. An intentional false clue.) 

( Build the travel table 23 ) += 
make Joe ( window , 

"You’re u at u a u low u window u overlooking u a u huge u pit , u \ 
which u extends u up u out u of \n\ 
sight . uu A u floor u is u indistinctly u visible u \ 
over u 50 u f eet u below . uu Traces u of \n\ 
white u mist u cover u the u f loor u of u the u pit , u \ 
becoming u thicker u to u the u lef t . \n\ 
Marks u in u the u dust u around u the u window u \ 
would u seem L jto u indicate Ll that\n\ 
someone u has u been u here u recently . uu \ 

Direct ly u across u the u pit u from u you u and\n\ 

25 u f eetuawayuthereuiSuausimilaruwindoWuS 
looking u into u a u lighted u room. \n\ 

A u shadowy u f igure u can u be u seen u there u \ 
peering u back u at u you. " , 
short-desc [windoe], 0); 
makeJnst (V , 0, sjunc ); 
makeJnst (JUMP, 0, neck); 


abovep = 81, §18. 
BEDQUILT =43, §9. 
bedquilt = 68, §18, §45. 
CLIMB =23, §9. 
crawl = 85, §18. 

CRAWL =21, §9. 

D = 9, §9. 

ditto = macro ( ), §21. 

JUMP = 22, §9. 

Iike4 =23, §18, §36. 

Iike6 = 25, §18, §36. 

Iike9 =28, §18, §36. 
low = 84, §18. 
makeJnst = macro ( ), §21. 
make Joe = macro ( ), §21. 
mirror = 94, §18, §52. 


N = 0, §9. 

neck = 130, §18, §60. 
ORIENTAL =46, §9. 
oriental = 87, §18, §50. 
OUT = 13, §9. 

PASSAGE =38, §9. 

S = 1, §9. 

scorr = 104, §18, §55. 

SE = 5, §9. 

short-desc: char *[], §20. 
sjunc = 82, §18, §48. 

SW = 7, §9. 
tite = 83, §18. 

W = 3, §9. 

windoe = 56, §18, §41. 
window = 86, §18, §49. 


290 Selected Papers on Fun and Games 

50. More treasures await you via the low corridor. 

( Build the travel table 23 ) += 

make Joe ( oriental , 

"This u is u the u Oriental u Room. uu \ 

Ancient u oriental u cave u drawings u cover u the\n\ 
walls . uu A u geiitly u sloping u passage u \ 

leads u upward u to u the u north, u another\n\ 
passage u leads u SE, u and u a u hands-and-knees u crawl u leads u west . " , 
"You’reuinuDrientaluRoom. " , 0); 
makeJnst) SE,0, cheese ); 
makeJnst (W, 0, low ) ; ditto (CRAWL ) ; 
makeJnst)V,0, misty); ditto )N); ditto (CAVERN); 
make Joe ( misty , 

"You u are u f ollowing u a u wide u path u \ 

around u the u outer u edge u of u a u large u cavern . \n\ 

Far u below , u through u a u heavy u white u mist , u \ 
str£inge u splashing u noises u caii u be\n\ 
heard . uu The u mist u rises u up u \ 

through u a u f issureuinutheijceiling . uu The u path\n\ 
exits u to u the u south u and u west . " , 

"You’re u in u misty u cavern. ", 0); 
makeJnst) S,0, oriental ); ditto (ORIENTAL); 
makeJnst (W, 0, alcove ) ; 

51. One of the darkest secrets is hidden here. You will discover that 
you must take the emerald from the Plover Room to the alcove. But you 
don’t learn the name of the Plover Room until the second time you’ve 
been there, since your first visit will be lampless until you know the 
secret. 

( Build the travel table 23 ) += 
make Joe ( alcove , 

"You u are u in u an u alcove . uu A u small u NW u path u \ 
seems u to u widen u after u a u short\n\ 
distance . uu An u extremely u tight u tunnel u \ 

leads u east . uu It u looks u like u a u very\n\ 
tight u squeeze . uu An u eerie u light u \ 

can u be u seen u at u the u other u end. " , 

"You’re u in u alcove. " , dark-hint); 
makeJnst) NW, 0, misty); ditto (CAVERN); 
makeJnst (E, 0, ppass ) ; ditto (PASSAGE ) ; 

makeJnst (E,0, proom); /* never performed, but seen by ‘go back' */ 

make Joe ( proom , 

"You’re u in u a u small u chamber u lit u by u an u eerie u green u light . uu \ 
An u extremely\n\ 


CAVE CONNECTIONS 


Adventure 291 


narrowutimneluexitsutoutheuwest . uu \ 
A u dark u corridor u leads u NE. " , 

"You’re u in u Plover u Room. " , lighted + dark-hint ); 
makeJnst (W, 0, ppass ) ; ditto (PASSAGE); ditto (OUT); 

makeJnst( W,0, alcove ); /* never performed, but seen by ‘go back’ */ 

makeJnst (PLOVER , holds ( EMERALD ) , pdrop ) ; 

makeJnst (PLOVER , 0, y2 ) ; 

makeJnst (NE, 0, droorn ); ditto (DARK); 

make Joe ( droom , 

" You ’ r e u in u the u Dark-Room . uu \ 

A u corridor u leading u south u is u the u only u exit . " , 
"You’re u in u Dark-Room. " , dark-hint ); 
makeJnst (S,0,proom ); ditto( PLOVER); ditto( OUT); 


alcove — 89, §18, §51. 
CAVERN = 39, §9. 
cheese =69, §18, §45. 
CRAWL = 21, §9. 

DARK = 66, §9. 
dark-hint = 128, §20. 
ditto = macro ( ), §21. 
droom = 91, §18. 

E = 2, §9. 

EMERALD =60, §11. 
holds = macro ( ), §21. 
lighted = 1, §20. 
low =84, §18, §48. 
makeJnst = macro ( ), §21. 
make-loc = macro ( ), §21. 
misty =88, §18, §50. 


N = 0, §9. 

NE = 4, §9. 

NW = 6, §9. 
oriental = 87, §18. 
ORIENTAL =46, §9. 
OUT = 13, §9. 

PASSAGE =38, §9. 
pdrop = 142, §18, §146. 
PLOVER = 72, §9. 
ppass = 141, §18, §146. 
proom = 90, §18. 

S = l, §9. 

SE = 5, §9. 

U = 8, §9. 

W = 3, §9. 
y2 =54, §18, §41. 


292 Selected Papers on Fun and Games 


52. We forgot to mention the circuitous passage leading west from 
the Twopit Room. It winds around and takes you to a somewhat more 
mundane area, yet not without interest. 

( Build the travel table 23 ) += 
makeJoc(slab , 



YoUuareuinuaulargeijlowucircularuchamberuX 
whose u f loor u is u an u immense u slab\n\ 
f allen u f rom u the u ceiling u (Slab u Eoom) . uu \ 
There u once u were u large u passages\n\ 
to u the u east u and u west , u but u they u are u noM u \ 


f illed u with u boulders . uu Low\n\ 


smallupassagesugOunorthuanduSouth.uX 
and u the u southuone u quickly u bends\n\ 
east u around u the u boulders . " , 

/* Woods originally said ‘west’ */ 
"You’reijinuSlab u Eoom. ", 0); 


make-inst( S , 0 , w2pit ) ; 

makeJnst (U, 0, abover ) ; ditto (CLIMB ) ; 

makeJnst) N, 0, bedquilt); 

make Joe ( abover , 

"You u are u inua u secret u N/SuCanyon u above u a u large u room. " , 0, 0); 

makeJnst (D, 0, slab ) ; ditto (SLAB ) ; 
makeJnst) S, not (DEAG0N, 0), scan2)\ 
makeJnst (S, 0, scanl ); 
makeJnst (N, 0, mirror)- 
makeJnst (EESEEV0IE, 0, res); 
make Joe ( mirror , 

"You u are u in u a u north/south u canyon u about u 25 u f eet u across . uu \ 
The u f loor u is\n\ 

covered u by u white u mist u seeping u in u f rom u the u north . uu \ 
The u walls u extend\n\ 
upward u f or u well u over u 100 u f eet . uu \ 

Suspended u from u some u unseen u point u f ar\n\ 
above u you, u Em u enormous u two-sided u mirror u \ 
is u hanging u parallel u to u and\n\ 
midway u between u the u canyon u walls . u \ 

u (The u mirror u is u obviously u provided\n\ 
for u the u use u of u the u dwarves )U \ 

who u as u you u know u are u extremely u vain . ) \n\ 
A u small u window u can u be u seen u in u either u wall , u \ 
some u f if ty u f eet u up . " , 

"You’re u in u mirror u canyon. " , 0); 

makeJnst( S,0, abover)- 

makeJnst( N, 0, res); ditto(EESEEVOIE); 



CAVE CONNECTIONS 


Adventure 293 


makeJoc(res, 

" You u are u at u the u edge u of u a u large u underground u reservoir . uu \ 
An u opaque u cloud\n\ 

of u white u mist u f ills u the u room u and u rises u rapidly u upward. uu \ 
The u lake u is\n\ 

fed u by u a u stream,uwhichutumblesuOutuof u a u hole u inuthe u wall u \ 
about u 10 u f eet\n\ 

overhead u and u splashes u noisily u into u the u water u \ 

somewhere u within u the\n\ 

mist . uu The u only u passage u goes u back u toward u the u south. " , 
"You’re u at u reservoir . " , liquid)- 
make.inst(S, 0, mirror ); ditto(WY)\ 


abover = 93, §18. 
bedquilt = 68 , §18, §45. 
CLIMB = 23, §9. 

D = 9, §9. 

ditto = macro ( ), §21. 
DRAGON =37, §11. 
liquid = 4, §20. 
makeSnst = macro ( ), §21. 
makeJoc = macro ( ), §21. 
mirror = 94, §18. 

N = 0, §9. 


not = macro ( ), §21. 
OUT = 13, §9. 
res = 95, §18. 
RESERVOIR = 44, §9. 
S = l, §9. 

scanl =96, §18, §53. 
scan2 = 97, §18, §53. 
slab = 92, §18. 

SLAB =36, §9. 

U = 8, §9. 

w2pit = 72, §18, §46. 


294 Selected Papers on Fun and Games 


53. Four more secret canyons lead back to the Hall of the Mountain 
King. Three of them are actually the same, but the dragon blocks the 
connection between the northern passage (to abover ) and the eastern 
passage (to secret). Once you’ve vanquished the dragon, scan2 takes 
the place of scanl and scan3 . 

( Build the travel table 23 ) += 
makeJoc(scanl , 

"You u are u in u a u secret u canyon u that u exits u to u the u north u and u east . " , 

0,0); 

makeAnst)N, 0, abover)', ditto( OUT); 
remark ( " The u dragon u looks u r ather u nasty . U u\ 
You’dubestunotutryutougetuby . " ); 
makeAnst (E, 0, sayit ) ; ditto (FORWARD ) ; 

make Joe )scan2 , long.desc[scanl ], 0, 0); 
makeAnst )N, 0, abover); 
makeAnst)E, 0, secret); 
make Joe ) scanS , long-desc [scanl ] , 0, 0) ; 
makeAnst) E, 0, secret); ditto) OUT); 
makeAnst (N, 0, sayit ) ; ditto (FORWARD ) ; 
make Joe ( secret , 

" You u are u in u a u secret u canyon , u which u here u rmis u E/W . uu \ 
It u crosses u over u a\n\ 
very u tight u canyon u 15 u f eet u below . uu \ 

If uyoUugOudownuyouumayijnotijbeuableNiA 
to u get u back u up . " , 

"You’re u in u secret u E/W u Ccmyonuabove u tight u Ccinyon. " , 0); 

makeAnst (E, 0, hmk ) ; 
makeAnst (W, not (DRAGON , 0) , scan2 ) ; 
makeAnst (W, 0, scan3 ) ; 
makeAnst) D, 0, wide); 


CAVE CONNECTIONS 


Adventure 295 


54. Below secret there’s another way to reach the cheese. 

( Build the travel table 23 ) += 
make Joe (wide , 

"You u are u at u a u wide u place u in u a u very u tight u N/Sucanyon. " , 0, 0); 
makeJnst( S,0, tight)-, 
makeJnst( N, 0, tail)-, 
make Joe (tight , 

"The u canyon u here u becomes u too u tightuto u go u further u south. " , 0 , 0); 

makeJnst( N, 0, wide); 

make Joe (tall , 

" You u are u in u a u tall u E/W u canyon . uu \ 

A u loM u tight u crawl u goes u 3 u f eet u north u and\n\ 
seems u to u open u up . " , 

"You’reuinutalluE/WijCanyon. " , 0); 

makeJnst( E, 0, wide); 
makeJnst (W, 0, boulders ) ; 
makeJnst( N,0, cheese); ditto( CRAWL); 
make Joe ( boulders , 

"The u canyon u runs u into u a u mass u ofuboulders u u dead u end. " , 0, 0); 

makeJnst( S, 0, tall); 


abover = 93, §18, §52. 
boulders = 103, §18. 
cheese = 69, §18, §45. 
CRAWL =21, §9. 

D = 9, §9. 

ditto = macro ( ), §21. 
DRAGON = 37, §11. 

E = 2, §9. 

FORWARD = 14, §9. 
hmk = 50, §18, §40. 
long-desc: char *[], §20. 
makeJnst = macro ( ), §21. 
makejoc = macro ( ), §21. 
N = 0, §9. 


not — macro ( ), §21. 

OUT = 13, §9. 

remark = macro ( ), §21. 

S = l, §9. 

sayit = macro, §21. 
scant = 96, §18. 
scan2 = 97, §18. 
scanS = 98, §18. 
secret = 99, §18, §53. 
tall = 102, §18. 
tight = 101, §18. 

W = 3, §9. 

wide = 100, §18, §54. 


296 Selected Papers on Fun and Games 


55. If you aren’t having fun yet, wait till you meet the troll. The only 
way to get here is to crawl southwest from the low room. And then 
you have a new problem to solve; we’ll see later that the TROLL and the 
BRIDGE are here. 

(Don Woods got the idea for the mist-covered bridge after an early 
morning visit to Mount Diablo; see Steven Levy, Hackers (New York: 
Delta, 1994), Chapter 7.) 

( Build the travel table 23 ) += 
make Joe (scorr , 

"You u are u in u a u long u winding u corridor u \ 

sloping u out u of u sight u in u both\n\ 
directions . " , 

"You’reuinuslopingucorridor . " , 0); 

makeJnst) D,0, low)-, 
makeJnst (U, 0, swside ) ; 
make Joe ( swside , 

"You u are u on u one u side u of u a u large , u deep u chasm. uu \ 
A u heavy u white u mist u rising\n\ 
up u f rom u below u obscures u all u view u of u the u f ar u side . uu \ 
A u SW u path u leads u away\n\ 
f rom u the u chasm u into u a u winding u corridor . " , 
"You’re u on u SW u side u of u chasm. " , 0); 
makeJnst{ SW, 0, scorr); 

remark ("Theutroll u refuses u to u let u you u cross . " ); 
makejnst (OVER , sees (TROLL), sayit); ditto) ACROSS); ditto(CROSS); 
ditto) NE); 

remark ("There u is u no u longer u any u way u across u the u chasm. " ); 
makeJnst (OVER, not (BRIDGE, 0), sayit); 
makeJnst (OVER, 0, troll); 
makeJnst ( JUMP , not (BRIDGE ,0), lose); 
makeJnst (JUMP , 0, bridge-rmk); 

56. The only things not yet explored on this side of the troll bridge 
are a dozen dead ends. They appear at this place in the ordering of 
all locations because of the pirate logic explained later: The pirate will 
never go to locations > dead3 . 

^define max-pirateJoc dead2 
( Build the travel table 23 ) += 
make Joe (deadO , dead-end , 0, 0); 
makeJnst) S, 0, cross); ditto (OUT); 
makeJoc)deadl , dead-end ,0, twist-hint); 
makeJnst (W, 0, likell ); ditto (OUT); 
make Joe )dead2 , dead-end , 0, 0); 


CAVE CONNECTIONS 


Adventure 


297 


make-inst) SE, 0, Ukel3); 

make-loc)dead3 , dead-end ,0, twist-hint)-, 
make-inst )V, 0, like 4 ); ditto) OUT); 

makeJoc)dead4 > dead-end , 0, twist-hint)-, 
makeAnst (E, 0, Hke4 ) ; ditto ( OUT ) ; 

makeJoc)dead5 , dead-end ,0, twist-hint); 
make-inst )\J, 0, likeS ); ditto(OUT); 

makeJoc(dead6 , dead-end, 0, twist-hint); 
make-inst )V, 0, like9); ditto (OUT); 

makeJoc(dead7 , dead-end, 0, twist-hint); 
make-inst) U, 0, UkelO); ditto(0\n); 

makeJoc)dead8 , dead-end, 0, 0); 
make-inst ( E, 0, brink ) ; ditto ( OUT ) ; 

makeJoc(dead9 , dead-end, 0, twist-hint); 
make-inst (S,0, likeS); ditto)0in); 

makeJoc)deadlO , dead-end ,0, twist-hint); 
make-inst) E, 0, likel2); ditto) OUT); 

makeJoc)deadl 1 , dead-end ,0, twist-hint); 
make-inst) U, 0, like8); ditto) OUT); 


ACROSS = 17, §9. 
BRIDGE = 39, §11. 
bridge-rmk-. int, §34. 
brink = 34, §18, §37. 
CROSS =25, §9. 
cross =49, §18, §40. 

0 = 9, §9. 

dead-end : char [], §21. 
deadO = 106, §18. 
deadl = 107, §18. 
dead2 = 108, §18. 
deadS = 109, §18. 
dead4 = 110, §18. 
dead5 = 111, §18. 
dead6 = 112, §18. 
deadl = 113, §18. 
dead8 = 114, §18. 
dead9 = 115, §18. 
deadlO = 116, §18. 
deadl 1 =117, §18. 
ditto = macro ( ), §21. 

E = 2, §9. 

JUMP =22, §9. 
likeS =22, §18, §36. 
Iike4 =23, §18, §36. 
Uke8 =27, §18, §36. 


Iike9 = 28, §18, §36. 

UkelO = 29, §18, §36. 
likell =30, §18, §36. 

Hkel2 = 31, §18, §36. 
likelS =32, §18, §36. 
lose = 131, §18, §60. 
low =84, §18, §48. 
make-inst = macro ( ), §21. 
make-loc = macro (), §21. 
NE = 4, §9. 
not = macro ( ), §21. 

OUT = 13, §9. 

OVER = 16, §9. 
remark = macro ( ), §21. 

S = 1, §9. 

sayit = macro, §21. 
scorr = 104, §18. 

SE = 5, §9. 

sees = macro ( ), §21. 

SW = 7, §9. 
swside = 105, §18. 

TROLL = 41, §11. 
troll = 143, §18, §146. 
twist-hint = 64, §20. 

U = 8, §9. 

W = 3, §9. 


298 Selected Papers on Fun and Games 

57. A whole nuther cave with nine sites and additional treasures is on 
tuther side of the troll bridge! This cave was inspired in part by J. R. R. 
Tolkien’s stories. 

( Build the travel table 23 } += 
make Joe (neside , 

"You u are u on u the u f ar u side u of u the u chasm. uu \ 
A u NE u path u leads u away u from u the\n\ 
chasm u on u this u side . " , 

"You’re u on u NE u side u of u chasm. " , 0); 
makeAnst (NE, 0, corr); 

makeAnst (OVER, sees (TROLL), sayit — 1); ditto (ACROSS); ditto (CROSS); 
ditto (SW); 

makeAnst (OVER, 0, troll); 
makeAnst ( JUMP , 0, bridge^rmk ) ; 
makeAnst (E0RR,0, fork); 
makeAnst (VIEW, 0, view); 
makeAnst ( BARREN , 0 , fbarr ) ; 

make Joe (corr , 

"You’re u in u a u long u east/westuCorridor . uu \ 

A u f aint u rumbling u noise u can u be\n\ 
heard u in u the u distance . " , 

" You ’ re u in u corr idor - " , 0) ; 
makeAnst (^1,0 , neside); 
makeAnst (E, 0 ,fork); ditto ( FORK); 
makeAnst (V IEW, 0, view); 
make Anst (BARREN, 0, fbarr); 

make Joe ( fork , 

"The u path u forks u here , U uThe u left u f ork u leads u northeast , uu \ 
A u dull u rumbling\n\ 

seems u to u get u louder u in u that u direction. uu \ 

The u right u f ork u leads u southeast\n\ 
down u a u gentle u slope . uu \ 

The u main u corridor u enters u f rom u the u west . " , 

"You’re u at u f ork u in u path. " , 0); 

makeAnst (W, 0, corr ) ; 

make Anst (HE, 0, warm); ditto (L); 

makeAnst(SE,0,lime); ditto( R); ditto) D); 

makeAnst (VIEW , 0, view ) ; 

makeAnst (BARREN , 0 , fbarr ) ; 

make Joe ( warm , 

"The u walls u are u quite u warm u here . uu \ 

FromutheunorthucauubeuhearduauSteadyNnX 
roar , uSo u loud u that u the u entire u cave u \ 


CAVE CONNECTIONS 


Adventure 


299 


seems u to u be u trembling . uu Another\n\ 
passage u leads u south, u and u a u low u crawl u goes u east . " , 
"You’reuatujunctionuwithuwarmuwalls . " , 0); 

makeAnst) S, 0,fork); ditto) FORK); 
makeAnst) N, 0, view); ditto (VIEW); 
makeAnst (E, 0, chamber ) ; ditto (CRAWL ) ; 


ACROSS =17, §9. 

BARREN =48, §9. 
bridgemmk : int, §34. 
chamber = 123, §18. 
com = 119, §18. 

CRAWL = 21, §9. 

CROSS =25, §9. 

D = 9, §9. 

ditto =macro (), §21. 

E = 2, §9. 
fbam = 125, §18. 
fork = 120, §18. 

FORK = 52, §9. 

JUMP = 22, §9. 

L = 10, §9. 
lime = 124, §18. 
makeAnst = macro ( ), §21. 


make-loc = macro (), §21. 
N = 0, §9. 

NE =4, §9. 
neside = 118, §18. 

OVER = 16, §9. 

R= 11, §9. 

S = l, §9. 

sayit = macro, §21. 

SE = 5, §9. 

sees = macro (), §21. 

SW = 7, §9. 

TROLL =41, §11. 
troll = 143, §18, §146. 
view = 122, §18. 

VIEW = 51, §9. 

W = 3, §9. 
warm = 121, §18. 


300 


Selected Papers on Fun and Games 
57. (continued) 

makeJoc(view , /* (John Gilbert co-authored this description.) */ 

" Y ou u are u on u the u edge u of u a u br eath-t aking u view . uu \ 
Far u below u you u is u an\n\ 
act ive u volcano , u f rom u which u great u gouts u \ 
of u molten u lava u come u surging\n\ 
out , u cascading u back u down u into u the u depths . uu \ 
The u glowing u rock u f ills u the\n\ 
f arthest u reaches u of u the u cavern u with u a u blood-red u glare >u \ 
giving u every-\n\ 

thing u an u eerie , u macabre u appearance . uu \ 

The u air u is u f illed u with u f lickering\n\ 
sparks u of u ash u and u a u heavy u smell u of u brimstone . uu \ 
The u walls u are u hot u to\n\ 

the u touch, u and u the u thundering u of u the u volcano u \ 
drowns u out u all u other\n\ 

sounds . uu Embedded u in u the u j agged u roof u f ar u overhead\ 
u are u myriad u twisted\n\ 

format ions , u composed u of u pure u whit e u alabas ter , \ 
uwhich u scatter u the u murky\n\ 
light u into u sinister u apparitions u upon u the u walls . uu \ 
To u one u sideuis u a u deep\n\ 

gorge , u f illed u with u a u bizarre u chaos u of u tortured u rock u \ 
that u seems u to u have\n\ 
been u craf ted u by u the u Devil u himself . uu \ 

An u immense u river u of u f ire u crashes\n\ 
out u from u the u depths u of u the u volcano )U \ 
burns u its u way u through u the u gorge , \n\ 
and u plummets u into u a u bottomless u pit u \ 
f ar u of f u to u your u lef t . uu To u the\n\ 
right .uanuimmenseugeyseruof u bli st er ing u st eam u \ 
erupt s u continuously\n\ 
f rom u a u barren u island u in u the u center u \ 

ofua u sulfurous u lake, u which u bubbles\n\ 
ominously . U uThe u far u right u wall u is u aflcune u \ 
with u an u incandescence u of u its\n\ 
own , u which u lends u an u addit ional u inf ernal u splendor u \ 
to u the u already\n\ 

hellish u scene . uu A u dark , u f oreboding u passage u \ 
exits u to u the u south. " , 

"You’re u atubreath-taking u view. " , lighted); 
makeJnst(S,0,warm); ditto (PASSAGE); ditto(OUT); 
make-inst (FORK , 0,/orfc); 

remark {default..msg[ EAT]); makeJnst(D,0,sayit); ditto) JUMP); 


CAVE CONNECTIONS 


Adventure 301 


make Joe ) chamber , 

" You u are u in u a u small u chamber u f illed u with u large u boulders . uu \ 
The u walls u are\n\ 

very u warm, u causing u the u air u in u the u room u tOube u \ 
almost u stif ling u f rom u the\n\ 
heat . uu The u only u exit u is u a u crawl u heading u west , u \ 
through u which u a u low\n\ 
rumbling u noise u is u coming. " , 

"You’re u in u chamber u of u boulders . " ,0); 
makeJnst (W, 0, warm ) ; ditto (OUT); ditto (CRAWL); 
makeJnst (FORK, 0 .fork)-, 
makeJnst)V IEW, 0, view)-, 
make Joe (lime , 

"You u are u walking u along u a u gently u sloping u \ 
north/ south u passage u lined u with\n\ 
oddly u shaped u limestone u f ormations . " , 

" You ’ r e u in u l ime s t one u pas sage . " , 0); 

make Jnst)N,0, fork ); ditto (U); ditto) FORK); 
makeJnst )S,0, fbarr ) ; ditto) D); ditto (BARREN); 
makeJnst (VIEW, 0, view)-, 
make Joe (Jbarr, 

"You u are u standing u at u the u entrance u \ 

to u a u large , u barren u room. uu A u sign\n\ 
posted u above u the u entrance u reads : UL ,\ 

\ "CAUTION ! uuBEAR u IN u R00M ! \ " " , 

"You’reuinufrontuofubarrenuroom. " , 0); /* don’t laugh too loud */ 

make Jnst)V,0, lime); ditto) U); 
makeJnst (FORK, 0,fork); 

makeJnst )E,0, barr); ditto) IN); ditto (BARREN); ditto (ENTER); 
makeJnst (VIEW, 0, view); 


barr = 126, §18. 

BARREN = 48, §9. 
chamber = 123, §18. 

CRAWL =21, §9. 

D = 9, §9. 

defaulhmsg: char *[], §15. 
ditto = macro ( ), §21. 

E = 2, §9. 

EAT, see §92 and §98. 
ENTER =20, §9. 
fbarr = 125, §18. 
fork = 120, §18. 

FORK =52, §9. 

IN = 12, §9. 

JUMP = 22, §9. 


lighted = 1, §20. 
lime = 124, §18. 
makeJnst = macro ( ), §21. 
make Joe = macro (), §21. 
N = 0, §9. 

OUT = 13, §9. 

PASSAGE =38, §9. 
remark = macro (), §21. 

S = l, §9. 

sayit = macro, §21. 

U = 8, §9. 
view = 122, §18. 

VIEW = 51, §9. 

W = 3, §9. 
warm = 121, §18. 


302 


Selected Papers on Fun and Games 

57. (continued (continued)) 
make Joe ( barr , 

"You u are u inside u a u barren u room. uu\ 

TheuCenteruofutheijroomuisuCompletelyNnX 
empty u except u f or u some u dust . u \ 

u Marks u in u the u dust u leaduawayutoward u the\n\ 
f ar u end u of u the u room. u \ 

u The u only u exit u is u the u way u you u came u in. " , 
"You’re u in u barren u room. " ,0); 
makednst(W,0,fbarr); ditto( OUT); 
makeJnst (FORK. 0,/orfc); 
makeJnst (VIEW, 0, view); 

58. The two storage locations are accessible only from each other, and 

they lead only to each other. 

( Build the travel table 23 ) += 
make Joe ( neend , 

"You u are u at u the u northeast u end u of u an u immense u room, u \ 
even u larger u than u the\n\ 

Giant u Room. uu It u appearstjto u be u a u repository u \ 
f or u the u \ "Adventure\ " \n\ 
program. uu Massive u torches u far u overhead u \ 
bathe u the u room u with u smoky\n\ 
yellow u light . uu Scattereduabout u you u can u be u seen u \ 
a u pile u of u bottles u (all\n\ 
of u them u empty) , u a u nursery u of u young u beanstalks u \ 
murmur ing u quietly , u a u bed\n\ 
of u oysters , u a u bundle u of u black u rods u \ 

with u rusty u stars u on u their u ends , u and\n\ 
a u collection u of u brass u lanterns . u \ 

u 0f f u to u one u side u a u great u many u dwarves\n\ 
are u sleeping u on u the u f loor , u snoring u loudly . uu \ 
A|_,sign u nearby u reads : uu \"D0\n\ 

NOT u DISTURB u THE u DWARVES ! \" u \ 

uAn u immense u mirror u is u hanging u against u one\n\ 
wall , u anduStretches u to u theuOther u enduOf u the u room , u \ 
where u various u other\n\ 

sundryuobjectsucanubeuglimpsedudimlyuinutheudistance . " , 
"You’re u at u NE u end. " , lighted); 
makeJnst (SW , 0, swend); 


CAVE CONNECTIONS 


Adventure 303 


makeJoc (swend, 

"You u are u atuthe u southwest u end u of u the u repository . uu \ 
To u one u side u is u a u pit\n\ 
full u of u f ierce u green u snakes . uu \ 

Onuthe u other u side u is u a u row u of u small\n\ 
wicker u cages , u each u of u which u contains u \ 
a u little u sulking u bird . U uIn u one\n\ 
corner u is u a u bundle u of u black u rods u \ 

Mith u rusty u marks u on u their u ends . \n\ 
A u large u number u of u velvet u pillows u \ 

are u scattered u about u on u the u f loor . \n\ 
A u vast u mirror u stretches u of f u to u the u northeast . uu \ 

At u your u f eet u is u a\n\ 

large u steel u grate, u nextuto u whichuis u a u sign u \ 
that u reads , u \ "TREASURE\n\ 

VAULT . uuKEYS u IN u MAIN u OFFICE . \ , 
"You’reuatuSWuend. " , lighted)', 
makeAnst (NE , 0, neend ) ; 
makeAnst (D. 0, grate -rmk)', 


barr = 126, §18. 

D = 9, §9. 

ditto = macro ( ), §21. 
fbarr = 125, §18. 
fork = 120, §18. 

FORK =52, §9. 
grate-rmk: int, §29. 
lighted = 1, §20. 
makeAnst = macro ( ), §21. 


makeJoc = macro ( ), §21. 
NE = 4, §9. 
neend = 127, §18. 

OUT = 13, §9. 

SW = 7, §9. 
swend = 128, §18. 
view = 122, §18. 

VIEW = 51, §9. 

W = 3, §9. 


304 Selected Papers on Fun and Games 

59. When the current location is crack or higher, it’s a pseudo- 
location. In such cases we don’t ask you for input; we assume that 
you have told us to force another instruction through. For example, if 
you try to go through the crack by the small pit in the upper cave (loca- 
tion spit), the instruction there sends you to crack , which immediately 
sends you back to spit. 

^define forced-move (loc) ( loc > min-forcedJoc) 

^define FORCE 0 /* actually any value will do here */ 

( Build the travel table 23 ) += 
make Joe (crack, 

"Theucrackuisuf arutoousmalluf or u you u to u f ollow . " , 0, 0); 
makeJnst (FORCE, 0, spit)-, 

60. Here are some forced actions that are less pleasant. 

( Build the travel table 23 } += 
make Joe (neck, 

"You u are u at u the u bottom u of u the u pit u with u a u broken u neck .",0,0); 
makeJnst (FORCE , 0, limbo ) ; 

makeJoc(lose , "Youudidn’tumakeuit . " , 0, 0); 
makeJnst (FORCE, 0, limbo)-, 

61. The rest are more-or-less routine, except for check — which exe- 
cutes a conditional forced command. 

( Build the travel table 23 ) += 
make Joe (cant, 

"The u dome u is u unclimbable . " , 0, 0); 
makeJnst (FORCE, 0, emist)\ 

make Joe (climb , 

"You u clamber u up u the u plant u \ 

and u scurry u through u the u hole u at u the u top . " , 0, 0); 
makeJnst (FORCE, 0, narrow ); 

make Joe ( check , " " , 0, 0) ; 

makeJnst (FORCE, no£(PLANT, 2), upnout)\ 

makeJnst (FORCE, 0, didit)-, 

make Joe (snaked , 

"You u can’t u get u by u the u snake . " , 0, 0); 

makeJnst ( FORCE , 0 , hmk ) ; 

make Joe (thru , 

"You u have u crawled u through u a u very u low u wide u passage u \ 
parallel u to u and u north\n\ 
of u the u Hall u of u Mists . " , 0, 0); 
makeJnst (FORCE, 0, wmist ); 


CAVE CONNECTIONS 


Adventure 305 


make Joe ( duck , long.desc [thru] ,0,0); 
makeJnst (FORCE , 0, wfiss); 

make Joe (sewer , 

"The u stream u f lows u out u through u \ 

a u pair u of u l-f oot-diameter u sewer u pipes . \n\ 
It u would u be u advisable u to u use u tIie u exit . " , 0, 0); 
makeJnst (FORCE, 0, house)-, 

make Joe ( upnout , 

"There u is u nothing u here u to u climb . uu \ 

Use u V'up\" u or u \"out V' u to u leaveuthe u pit . " , 0 , 0 ); 

makeJnst (FORCE , 0, wpit); 
make Joe (didit , 

"You u have u climbed u up u the u plantuanduOut u of u the u pit . " , 0, 0); 
makeJnst (FORCE , 0, w2pit); 

62. The table of instructions ends here; the remaining “locations” 
ppass, pdrop, and troll are special. 

{ Build the travel table 23 ) +s 
start [ppass] = q; 

if (q > & travels [travel-size] V rem.count > remsize) { 
printf ( " Oops , U I > m u br oken ! \n" ) ; exit ( - 1 ) ; 

} 


cant = 132, §18. 
check = 134, §18. 
climb = 133, §18. 
crack = 129, §18. 
didit = 140, §18. 
duck = 137, §18. 
emist = 15, §18, §32. 
exit-, void (), <stdlib.h>. 
hmk = 50, §18, §40. 
house =3, §18, §25. 
limbo =0, §18. 
loc: location, §74. 
long.desc: char *[], §20. 
lose = 131, §18. 
makeJnst = macro ( ), §21. 
makejoc = macro ( ), §21. 
minJorcedJoc = 129, §18. 
narrow =75, §18, §47. 
neck = 130, §18. 
not = macro (), §21. 


pdrop = 142, §18, §146. 

PLANT = 28, §11. 

ppass = 141, §18, §146. 

printf: int (), <stdio.h>. 

q: register instruction *, §22. 

rem^count: int, §20. 

remsize = 15, §20. 

sewer = 138, §18. 

snaked = 135, §18. 

spit = 14, §18, §31. 

start: instruction *[], §20. 

thru = 136, §18. 

traveLsize = 740, §20. 

travels: instruction [], §20. 

troll = 143, §18, §146. 

upnout = 139, §18. 

w2pit = 72, §18, §46. 

wfiss = 18, §18, §34. 

wmist = 19, §18, §35. 

wpit = 74, §18, §46. 


306 Selected Papers on Fun and Games 

63. Data structures for objects. A fixed universe of objects was 
enumerated in the vocabulary section. Most of the objects can move or 
be moved from place to place; so we maintain linked lists of the objects 
at each location. The first object at location l is first [l], then comes 
link [first [l]], then link [link {first [l]]], etc., ending with 0 (which is the 
“object” called NOTHING). 

Some of the objects are placed in groups of one or more objects. In 
such cases 6ase[t] is the smallest object in the group containing object t. 
Objects that belong to groups are immovable; they always stay in the 
same location. Other objects have base[t ] = NOTHING and they are free 
to leave one list and join another. For example, it turns out that the 
KEYS are movable, but the SNAKE is always in the Hall of the Mountain 
King; we set base [KEYS] = NOTHING and base [SNAKE] = SNAKE. Several 
groups, such as the GRATE and GRATE_, consist of two objects. This 
program supports operations on groups of more than two objects, but 
no such objects actually occur. 

Each movable or base object t has a current property prop[t], which 
is initially —1 for treasures, otherwise initially 0. We change prop[t\ to 0 
when you first see treasure t; and property values often change further 
as the game progresses. For example, the PLANT can grow. When you 
see an object, we usually print a message that corresponds to its current 
property value. That message is the string note[prop[t ] + offset [t}\. 

(Exception: When you first see the RUG or the CHAIN, its property 
value is set to 1, not 0. The reason for this hack is that you get maximum 
score only if the property values of all treasures are zero when you finish.) 

Each object is in at most one list, place [f]. If you are carrying object t, 
the value of place[t\ is inhand , which is negative. The special location 
limbo has value 0; we don’t maintain a list first [limbo] for objects that 
have place [t] = limbo . Thus object t is in a list if and only if place [t] > 0. 
The global variable holding counts how many objects you are carrying. 

One more array completes our set of data structures: Objects that 
appear in inventory reports have a name, name[t\. 

#define toting (t) (place [t] < 0) 

( Global variables 7 ) += 

object first [max Joe + 1]; /* the first object present at a location */ 

object link[max-obj +1]; 

/ * the next object present in the same location * / 
object base [max-obj + 2]; 

/* the smallest object in each object’s group, if any */ 
int prop[max-obj + 1]; /* each object’s current property value */ 

location place[max-obj + 1]; /* each object’s current location */ 


DATA STRUCTURES FOR OBJECTS 


Adventure 307 


char *name [max^obj + 1]; /* name of object for inventory listing */ 

char *no<e[100]; /* descriptions of object properties */ 

int offset[max-obj + 1]; /* where notes for each object start */ 

int holding ; /* how many objects have prop[t\ <0? */ 

int note-ptr — 0; /* how many notes have we stored? */ 

64. Here then is a simple subroutine to place an object at a given 
location, when the object isn’t presently in a list. 

{ Subroutines 6 ) += 

void drop ARGS((object, location)); 
void drop(t,l) 
object t; 
location 1; 

{ _ 

if (toting (f)) holding — ; 
place [t] = l ; 
if (l < 0) holding ++; 
else if (/ > 0) { 
link [t] = first [/] ; 
first [l] = t ; 

} 

} 


ARGS = macro ( ), §3. 
CHAIN =66, §11. 

GRATE =3, §11. 

GRATE_ =4, §11. 
inhand = —1, §18. 

KEYS = 1, §11. 
limbo = 0, §18. 
location = enum, §18. 


max-loc = 140, §18. 
max-obj =66, §11. 

NOTHING =0, §11. 
object =enum, §11. 
PLANT =28, §11. 

RUG = 63, §11. 

SNAKE = 13, §11. 


308 Selected Papers on Fun and Games 

65. Similarly, we need a subroutine to pick up an object. 

#define move(t,l) { carry (t); drop(t,l); } 

#define destroy (t) move(t, Umbo) 

( Subroutines 6 ) += 

void carry ARGS((object)); 
void carry (t) 
object t; 

{ register location l = place[t\; 
if (/ > limbo) { 
place[t] = inhand ; 
holding -H- ; 
if ( l > limbo) { 

register object r, s; 

for (r = 0,s = first [l]; s / t; r = s,s = link[s]) ; 
if (r = 0) first[l] = link[s]\ 

else link[r] = link [s] ; /* remove t from list */ 

} 

} 

} 

66. The is-atJoc subroutine tests if a possibly multipart object is at a 
particular place, represented by the global variable loc. It uses the fact 
that multipart objects have consecutive values, and base[maxmbj +1] = 

NOTHING. 

( Subroutines 6 ) += 

boolean is.atJoc ARGS ((object)); 

boolean is_atJoc(t) 

object t; 

{ 

register object tt; 

if ( base[t ] = NOTHING) return place [f] = loc- 
for (tt = t; base[tt] = t\ tt++) 
if (place [tt] = loc) return true; 
return false; 

} 


DATA STRUCTURES FOR OBJECTS 


Adventure 


309 


67. A few macros make it easy to get each object started. 

^define new-obj (t,n,b,l) 

{ /* object t named n with base b starts at l */ 

name[t ] = n; 
base [t] = b ; 
offset[t\ = note-ptr ; 
prop[t\ = ( is-treasure(t ) ? —1 : 0); 
drop(t, /); 

} 

#define new-.note(n) note [not e_p tr -H-] = n 

68. (Additional local registers 22 ) += 

register object t ; 


ARGS = macro (), §3. 
base : object [], §63. 
boolean = enum, §2. 
drop : void ( ), §64. 
false = 0, §2. 
first : object [], §63. 
holding : int, §63. 
inhand = — 1, §18. 
is.treasure = macro ( ), §11. 
limbo = 0, §18. 
link: object [], §63. 
loc: location, §74. 


location = enum, §18. 
max-obj = 66 , §11. 
name: char *[], §63. 
note: char *[], §63. 
notejptr: int, §63. 
NOTHING = 0, §11. 
object =enum, §11. 
offset: int [], §63. 
place: location [], §63. 
prop: int [], §63. 
true = 1, §2. 


310 Selected Papers on Fun and Games 

69. Object data. Now it’s time to build the object structures just 
defined. 

We put the objects into their initial locations backwards, that is, 
highest first; moreover, we place all two-part objects before placing the 
others. Then low-numbered objects will appear first in the list, and 
two-part objects will appear last. 

Here are the two-part objects, which are mostly unnamed because you 
won’t be picking them up. 

( Build the object tables 69 ) = 
new-obj (RUG_, 0, RUG, scanS ); 
new-obj (RUG, "Persian u rug" , RUG, scant ); 

new-note ("There u is u a u Persian u rug u spread u out u on u the u f loor ! " ); 
nete_note("The u dragon u iSusprawled u out u on u a u Persian u rug! ! " ); 
new-obj (TR0LL2_, 0, TR0LL2, limbo); 
new-obj (TR0LL2, 0, TR0LL2, limbo); 
new-note ("The u troll u is u nowhere u to u be u seen. " ); 
new-obj (TRQLL_, 0, TROLL, neside); 
new-obj (TROLL, 0, TROLL, swside); 
netr-note("A u burly u troll u stands u by u the u bridge u \ 
and u insists u you u throw u him u a\n\ 
treasure u bef ore u you u may u cross . " ); 
new_no<e ("TheutrolluStepsuOutufroniubeneathutheubridgeuX 
and u blocks u your u way . " ); 
new-note ( 0); 

new-obj (BRIDGE,, 0, BRIDGE, neside); 
new-obj (BRIDGE, 0, BRIDGE, swside); 

new-note ("A u r ickety u wooden u br idge u extends u acr os s u the u chasm, u \ 
vanishing u into u the\n\ 

mist . uu A u sign u posted u oii u the u bridge u reads , u \ 

\ " STOP ! U uPAYuTR0LL ! \ " " ) ; 

nety_note("The u wreckage u of u a u bridge u (and u a u dead u bear) u \ 
can u be u seen u at u the u bottom\n\ 
of u the u chasm. " ); 

new-obj (DRAGON, , 0, DRAGON, scan3); 
new-obj (DRAGON, 0, DRAGON, scanl ); 

net/)_riote("A u huge u green u f ierce u dragon u bars u the u way ! " ); 
ne«nno£e("Congratulations ! uu \ 

YouuhaveujustuvaiiquisheduaudragonuWithuyourubareXnX 
hands ! u (Unbelievable , u isn't u it?) " ); 
new-note ( " The u body u of u a u huge u green u deadudragon u \ 
is u lying u of f u to u one u side . " ); 
new-obj (SHADOW, , 0, SHADOW, window); 
new-obj (SHADOW, 0, SHADOW, windoe); 


OBJECT DATA 


Adventure 311 


new-note ( "The u shadowy u f igur e u \ 

seems u to u beutrying u to u attract u your u attention. " ); 
new-ohj (PLANT2_ , 0, PLANT2, e2pit); 
new-obj (PLANT2 , 0, PLANT2, w2pit); 
new-note (0); 

new.note ("The u top u of u a u 12-f oot-tall u beanstalk u \ 
isupokinguoutyof u the u west u pit . " ); 
net«_note("There u is u a u huge u beanstalk u \ 

growing u out u of u the u west u pit u up u to u the u hole . " 
neu)-obj (CRYSTAL., 0, CRYSTAL, wfiss); 
new-obj (CRYSTAL, 0, CRYSTAL, efiss); 
new.note (0); 

new-note ("A u cry st al u bridge u now u spans u the u f is sure . " 
new.note ("The u crystal u bridge u has u vanished! " ); 
new-obj (TREADS., 0, TREADS, emist); 
new-obj (TREADS , 0, TREADS , spit ) ; 

new.note ("Rough u stone u steps u lead u down u the u pit . " ); 
neui.note("Rough u stone u steps u lead u up u the u dome. " ); 
new-obj (GRATE. , 0, GRATE , inside ) ; 
new-obj (GRATE, 0, GRATE, outside ); 
riew_note("The u grate u is u locked. " ); 
new_noie("The u grate u is LJ open. " ); 

new-obj (MIRROR. , 0, MIRROR, limbo); /* joins up with MIRROR later */ 
See also section 70. 

This code is used in section 200. 


BRIDGE =39, §11. 
BRIDGE. =40, §11. 
CRYSTAL = 14, §11. 
CRYSTAL. = 15, §11. 
DRAGON = 37, §11. 
DRAGON. =38, §11. 
e2pit = 71, §18, §46. 
efiss = 17, §18, §34. 
emist = 15, §18, §32. 
GRATE =3, §11. 

GRATE. =4, §11. 
inside = 9, §18, §30. 
limbo = 0, §18. 

MIRROR = 26, §11. 
MIRROR. =27, §11. 
neside = 118, §18, §57. 
new^note = macro ( ), §67. 
new-obj = macro ( ), §67. 
outside = 8, §18, §29. 
PLANT2 =29, §11. 


PLANT2. = 30, §11. 
RUG = 63, §11. 

RUG. =64, §11. 
scant =96, §18, §53. 
scanS = 98, §18, §53. 
SHADOW = 32, §11. 
SHADOW. =33, §11. 
spit = 14, §18, §31. 
swside = 105, §18, §55. 
TREADS =8, §11. 
TREADS. =9, §11. 
TROLL =41, §11. 
TROLL. =42, §11. 
TR0LL2 =43, §11. 
TR0LL2. =44, §11. 
w2pit = 72, §18, §46. 
wfiss = 18, §18, §34. 
windoe = 56, §18, §41. 
window =86, §18, §49. 


312 Selected Papers on Fun and Games 

70. And here are the one-place objects, some of which are immovable 
(because they are in a group of size one). 

( Build the object tables 69 ) += 

new-obj (CHAIN, "Golden u chain" , CHAIN, barr); 

new-note ("Thereuis u a u golden u chain u lying u inua u heap u on u the u f loor ! " ); 
new.note ("The u bear u is u locked u to u the u wall u with u a u goldenuchain ! " ); 
rie«;_note("There u is u a u golden u chain u locked u to u the u wall ! " ); 
nevi-obj (SPICES, "Rare u spices" , 0, chamber); 
neui_note("There u are u rare u spices u here ! " ); 
new-obj (PEARL, "Glistening u pearl" ,0, limbo); 
neuunofe( M Off u to u one u sideulies u a u glistening u pearl ! " ); 
new.obj (PYRAMID, "Platinum u pyramid" ,0, droom); 

neK)-no<e("There u is u a u platinuin u pyramid u here, u 8 u inches u on u a u side ! " ); 
new.obj (EMERALD, "Egg-sized u emerald" , 0, proom); 

new-note ("There u is u an u emerald u here u the u size u of u a u plover ’ s u egg ! " ); 
new-obj (VASE, "Ming u vase" , 0, oriental); 

neui_note("There u is u a u delicate )U precious , u Ming u vase u here ! " ); 
new-note ( "The u vase u is u now u rest ing , u delicately , u \ 
on u a u velvet u pillow . " ) ; 
ne«J_nofe("The u f loor u is u littered u \ 

withuworthlessushardsuofupottery . " ); 
neio_wote("The u Ming u vaseudropSuwith u a u delicate u crash. " ); 
new-obj (TRIDENT, " Jeweled u trident" , 0, falls); 
neru_note("Thereuis u a u jewel-encrusted u tridentuhere ! " ); 
new-obj (EGGS, "Golden u eggs" , 0, giant); 

new-note ("There u is u a u large u nest u here , u full u of u golden u eggs ! " ); 
neMU7iofe("The u nest u of u golden u eggs u has u vanished! " ); 
new-note(" Done! "); 

new-obj (CHEST, "Treasure u chest" , 0, limbo); 

nett)_note("The u pirate’s u treasure u chest u is u here ! " ); 

new-obj (COINS, "Rare u coins" , 0, west); 

neiti_raote("There u are u many 1J coins u here ! " ); 

new-obj (JEWELS, "Precious u jewelry" , 0, south); 

net«_note("There u is u precious u jewelry u here ! " ); 

new-obj (SILVER, "Bars u of u silver" , 0 ,ns); 

new-note ("There u are u bars u of u silver u here ! " ); 

new-obj (DIAMONDS, "Several u diamonds" , 0, wfiss); 

new-note ("There u are u diamonds u here ! " ); 

new-obj (GOLD, "Large u gold u nugget" , 0, nugget); 

nen;_raote("There u iSua u large u sparkling u nuggetuof u gold u here ! " ); 

new-obj (MOSS, 0, MOSS, soft); new-note (0); 

new-obj (BATTERIES , "Batteries" , 0, limbo); 

neu)_note("There u are u fresh u batteries u here. " ); 

ne?r_uo<e("Some u worn-out u batteries u have u beeii u discarded u nearby . " ); 


OBJECT DATA 


Adventure 313 


new-obj (PONY , 0, PONY , pony ) ; 

new_note ("There u is u a u massive u vending u machine u here . uu \ 
The u instructions u on u it u read: \n\ 
V'Drop u coins u here u to u receive u fresh u batteries . ); 
neuj-obj (GEYSER, 0, GEYSER, view)', new-note(0); 
new.obj (MESSAGE , 0, MESSAGE , limbo ) ; 
new-note ("There u is u a u message u scrawled u in u the u dust u \ 
in u a u f lowery u script , u reading : \n\ 
\"This u is u not u the L jmaze u where L j\ 

the u pirate u hides u his u treasure u chest . \" " ); 
new-obj (BEAR, 0, BEAR, barr); 
neucnote ("There u is u a u f erocious u cave u bear u \ 

e yinguyou u from u the u far u end u of u the u room! " ); 
neu)_note("There u is u a u gentle u cave u bear u \ 

sitting u placidly u in u one u corner . " ); 
neW-no<e("There u isua u contented-looking u bear u \ 
wander ing u about u nearby . " 
new .note (0); 

new-obj (PIRATE, 0, PIRATE, limbo); 
new-note(O); 

new-obj (ART, 0, ART, oriental); new-note{ 0); 
new-obj (AXE, "Dwarf ’ s u axe" , 0, limbo); 
new.note ( "There u is u a u little u axe u here . " ) ; 

netr_note ("Thereuisuaulittleuaxeulyingubesideutheubear . " ); 

new-obj (STALACTITE, 0, STALACTITE, tite); neW-note( 0); 


ART = 35, §11. 

AXE =34, §11. 
barr = 126, §18, §57. 
BATTERIES = 49, §11. 
BEAR = 45, §11. 

CHAIN =66, §11. 
chamber = 123, §18, §57. 
CHEST = 56, §11. 

COINS =55, §11. 
DIAMONDS =52, §11. 
droom = 91, §18, §51. 
EGGS =57, §11. 

EMERALD =60, §11. 
falls = 79, §18, §47. 
GEYSER = 47, §11. 
giant = 76, §18, §47. 

GOLD =51, §11. 

JEWELS =54, §11. 
limbo = 0, §18. 

MESSAGE =46, §11. 

MOSS =50, §11. 
newmote = macro ( ), §67. 


new-obj = macro (), §67. 
ns = 53, §18, §41. 
nugget = 16, §18, §33. 
oriental = 87, §18, §50. 
PEARL =62, §11. 

PIRATE = 36, §11. 

PONY =48, §11. 
pony =48, §18, §39. 
proom = 90, §18, §51. 
PYRAMID =61, §11. 
SILVER = 53, §11. 
soft = 70, §18, §45. 
south = 52, §18, §40. 
SPICES =65, §11. 
STALACTITE = 31, §11. 
tite = 83, §18, §48. 
TRIDENT = 58, §11. 

VASE = 59, §11. 
view = 122, §18, §57. 
west = 51, §18, §40. 
wfiss = 18, §18, §34. 


314 


Selected Papers on Fun and Games 
70. (continued) 

new-obj (PLANT, 0, PLANT, wpit); 

new-note ("There u is u a u tiny u little u plantuin u the u pit , u \ 
murmuringuV'Water >u water, u . . A""); 
neu)-note("The u plant u spurts u into u furious u growth u \ 
f or u a u f ew u seconds . " 

new.note ("There u is u a u 12-f oot-tall u beanstalk u \ 
stretching u up u out u of u the u pit , \n\ 
bellowing u \ "Water ! ! uu Water! !\""); 
new. note ( "The u plant u grows u explosively , u \ 

almost u f illing u the u bottom u of u the u pit . " 
new.note ("There u is u a u gigantic u beanstalk u \ 

stretching u all u the u way u up u to u the u hole . " 
new.note ('"{on’ ve u over-watered u the u plant ! uu \ 

It ’ s u shriveling u up ! uu It ’ s , u it ’ s . . . " ); 
new.obj (MIRROR, 0, MIRROR, mirror)-, new.note ( 0); 
new.obj (OIL, "Oil u inuthe u bottle" , 0, limbo); 
new.obj (WATER, "Water u in u the u bottle" , 0, limbo); 
new.obj (BOTTLE, "Small u bottle" , 0, house); 
new.note ("ThereuiSuaubottleuOf u water u here . " 
new.note ("There u is u an u empty u bottle u here . " 
neuL7iote("There u is u a u bottle u of u oil u here . " ); 
new.obj (FOOD, "Tasty u f ood" , 0, house); 
new.note ("TheTe u is u t ood u here . " ); 
new.obj (KNIFE, 0, 0, limbo); 
new.obj (DWARF , 0, DWARF , limbo ) ; 
new.obj (MAG, "\"Spelunker u Today\" " , 0, ante); 
neiu_7io<e("There u are u a u f ew u recent u issues u \ 

of u \"Spelunker u Today\" u magazine u here . " 
new.obj (OYSTER, "Giant u oyster u >GR0AN ! <" , 0, limbo); 
new.note ("There u is u aii u enormous u oy st er u here u \ 
with u its u shell u tightly u closed. " ); 
new.note ( " Interesting . uu There u seems u to u be u \ 

something u written u on u the u underside u of \n\ 
the u oyster . " ); 

new.obj (CLAM, "Giant u clam u >GRUNT ! <" , 0, shell); 
nety_note("There u is u an u enormous u clain u here u \ 
with u its u shell u tightly u closed. " ); 
new.obj (TABLET, 0, TABLET, droom); 

new.note (" A u massive u stoneutablet u embedded u in u the u wall u reads : \n\ 

\ "C0NGRATULATI0NSu0N u BRINGINGuLIGHT u INT0uTHE u D ARK-R00M ! \" " ); 
new.obj (SNAKE, 0, SNAKE, hmk); 

nein_noie("A u huge u green u f ierce u snake u bars u the u way ! " ); 
new.note (0); 


OBJECT DATA 


Adventure 315 


new-obj (PILLOW, "Velvet u piIlow" , 0, soft); 
new-note ( " Ausmall u velvet u pillow u lies u on u the u f loor . " ) ; 
new-obj (DOOR, 0, DOOR, immense ) ; 
ne«;-note("The u May u north u is u barred Ll by u a u \ 
massive, u rusty, u iron u door. " ); 
new-note ( "The u way u north u leads u through u a u \ 
massive, u rusty, u iron u door. " ); 
new-obj (BIRD, "Little u bird u in u cage" , 0, bird); 
raeu)_note("A u cheerfululittle u birduis u sittinguhere u singing. " ); 
ne?i)_note ("Thereuis u a u littleubirduinuthe u cage . " 
new-obj (R0D2, "Black u rod" , 0, limbo); 
new-note ( " A u three-f oot u black u r od u \ 

with u a u rusty u mark u on u an u end u lies u nearby . " ); 
new-obj (ROD, "Black u rod" , 0, debris); 
new.note ( " A u three-f oot u black u rod u \ 

with u a u riisty u star u on u an u end u lies u nearby . " ); 
new-obj (CAGE, "Wicker u cage" , 0, cobbles); 

new-note ("There u is u a u small u wicker u cage u discarded u nearby . " ); 

new-obj (LAMP, "Brass u lantern" , 0, house); 

new-note ( "There u is u a u shiny u brass u lamp u nearby . " ) ; 

new-note ("There u is u a u lainp u shining u nearby . " ); 

new^obj (KEYS, "Set u of u keys" , 0, house); 

new-note ("There u are u some u keys u on u the u ground u here . " 


ante = 66, §18, §44. 
BIRD = 10, §11. 
bird = 13, §18, §31. 
BOTTLE = 23, §11. 

CAGE =5, §11. 

CLAM = 17, §11. 
cobbles = 10, §18, §31. 
debris = 11, §18, §31. 
DOOR = 11, §11. 
droom =91, §18, §51. 
DWARF =20, §11. 

FOOD = 22, §11. 
hmk = 50, §18, §40. 
house =3, §18, §25. 
immense = 78, §18, §47. 
KEYS = 1, §11. 

KNIFE = 21, §11. 

LAMP =2, §11. 


limbo = 0, §18. 

MAG = 19, §11. 

MIRROR = 26, §11. 
mirror = 94, §18, §52. 
new-note = macro ( ), §67. 
new-obj = macro ( ), §67. 
OIL = 25, §11. 

OYSTER = 18, §11. 

PILLOW = 12, §11. 

PLANT = 28, §11. 

ROD =6, §11. 

R0D2 =7, §11. 
shell = 62, §18, §43. 

SNAKE = 13, §11. 
soft = 70, §18, §45. 

TABLET = 16, §11. 

WATER = 24, §11. 
wpit = 74, §18, §46. 


316 Selected Papers on Fun and Games 

71 . Low-level input. Sometimes we need to ask you a question, 
for which the answer is either yes or no. The subroutine yes(q,y,n) 
prints q, waits for you to answer, and then prints y or n depending on 
your answer. It returns a nonzero value if your answer was affirmative. 

( Subroutines 6 } += 

boolean yes ARGS((char *, char * . char *)); 

boolean yes(q,y,n ) 
char *q, *y, *n ; 

{ 

while (1) { 
printf s\n\ 

fflush(stdout ); 
fgets (buffer , bupsize, stdin); 
if ( tolower (*buffer ) = ’y’) { 

if (y) printf ("’/, s\n" , y); return true; 

} 

else if (tolower (*buffer) = ’n’) { 

if (n) printf (" ’/,s \n" , n); return false; 

} 

else print/ ("uPleaseuansweruYesuoruNo . \n" ); 

} 

} 

72. The only other kind of input is almost as simple. You are supposed 
to tell us what to do next in your adventure, by typing one- or two- word 
commands. We put the first word in wordl and the (possibly null) 
second word in word2 . Words are separated by white space; otherwise 
white space is ignored. 

( Subroutines 6 ) += 

void listen ARGS((void)); 

void listen ( ) { 

register char *p, *q; 

while (1) { 

printf ("* u "); fftush(stdout); 
fgets (buffer , bufsize, stdin ); 
for (p = buffer; isspace(*p); p++) ; 
if (*p = 0) { 

printf (" u Tell u me u to u do u something . \n" ); continue; 

} 

for (q = wordl ; *p; p++,q++) { 
if (isspace(*p)) break; 

*q = tolower (*p); 

} 


LOW-LEVEL INPUT 


Adventure 317 


*q = ’ \0 ’ ; /* end of wordl * / 

for (p++; isspace(*p); p++) ; 
if ( *p = 0) { 

*word2 = ’ \0 return; 

} 

for (q = word2', *p ; p-H-,q++) { 
if ( isspace(*p )) break; 

*q = tolower (*p ) ; 

} 

*q = ’ \0 ’ ; /* end of word2 * / 

for (p++; isspace(*p); p++) ; 

if ( *p = 0) return; 

printf ("uPlease u stick u to u l-uand u 2-word u conraiands . \n" ); 

} 

} 

73. A 20-character buffer would probably be big enough, but what the 
heck. 

#define bufsize 72 
{ Global variables 7 } += 

char buffer [bufsize\] /* your input goes here */ 
char wordl [buffsize], word2[buffsize]; 

/ * and then we snarf it to here * / 


ARGS = macro ( ), §3. 
boolean = enum, §2. 

false = 0, §2. 

jj Hush: int (), <stdio.h>. 
fgets: char *(), <stdio.h>. 
isspace: int (), <ctype.h>. 


printf : int (), <stdio.h>. 
stdin: FILE *, <stdio.h>. 
stdout: FILE *, <stdio.h> 
tolower: int (), <ctype.h>. 

true = I, §2. 


318 Selected Papers on Fun and Games 

74. The main control loop. Now we’ve got enough low-level mech- 
anisms in place to start thinking of the program from the top down, and 
to specify the high-level control. 

A global variable loc represents where you currently live in the simu- 
lated cave. Another variable newloc represents where you will go next, 
unless something like a dwarf blocks you. We also keep track of oldloc 
(the previous value of loc ) and oldoldloc (the previous previous value), 
for use when you ask to ‘go back’. 

^define here(t) ( toting(t ) V place[t\ = loc) /* is object t present? */ 
#define water-here (( flags [loc ] & ( liquid + oil)) = liquid) 

# define oiLhere (( flags[loc\ & ( liquid + oil)) = liquid + oil) 

^define no -liquid -here (( flags[loc ] & liquid) = 0) 

( Global variables 7 ) += 

location oldoldloc , oldloc , loc, newloc ; 

/* recent and future locations */ 

75. Here is our overall strategy for administering the game. It is 
understood that the program might goto quit from within any of the 
subsections named here, even though the section names don’t mention 
this explicitly. For example, while checking for interference we might 
find out that time has run out, or that a dwarf has killed you and no 
more reincarnations are possible. 

The execution consists of two nested loops: There are “minor cycles” 
inside of “major cycles.” Actions define minor cycles in which you stay 
in the same place and we tell you the result of your action. Motions 
define major cycles in which you move and we tell you what you can see 
at the new place. 

( Simulate an adventure, going to quit when finished 75 ) = 

while (1) { 

(Check for interference with the proposed move to newloc 153); 
loc = newloc, /* hey, we actually moved you */ 

(Possibly move dwarves and the pirate 161 ); 
commence : ( Report the current state 86 ) ; 
while (1) { 

(Get user input; goto try-move if motion is requested 76); 

( Perform an action in the current place 79 ) ; 

} 

try-move: ( Handle special motion words 140 ); 
oldoldloc = oldloc, 
oldloc = loc, 

go-for-it: (Determine the next location, newloc 146); 

} 

This code is used in section 2. 




THE MAIN CONTROL LOOP 


Adventure 319 


flags: int [], §20. 
liquid = 4, §20. 

location = enum, §18. 
oil = 2, §20. 


place: location [], §63. 
quit: label, §2. 
toting = macro ( ), §63. 


320 Selected Papers on Fun and Games 

76. Our main task in the simulation loop is to parse your input. 
Depending on the kind of command you give, the following section of 
the program will exit in one of four ways: 

• goto try-move with mot set to a desired motion. 

• goto transitive with verb set to a desired action and obj set to the 
object of that motion. 

• goto intransitive with verb set to a desired action and obj — NOTHING; 
no object has been specified. 

• goto speakit with hash-table [k]. meaning the index of a message for a 
vocabulary word of message-type. 

Sometimes we have to ask you to complete an ambiguous command 
before we know both a verb and its object. In most cases the words can 
be in either order; for example, ‘take rod’ is equivalent to ‘rod take’. 
A motion word overrides a previously given action or object. 

Lots of special cases make the program a bit messy. For example, if 
the verb is ‘say’, we don’t want to look up the object in our vocabulary; 
we simply want to “say” it. 

( Get user input; goto try-move if motion is requested 76 ) = 
verb = oldverb = ABSTAIN; 
oldobj = obj\ 

obj = NOTHING; 

cycle: (Check if a hint applies, and give it if requested 195); 

(Make special adjustments before looking at new input 85 ); 
listen ( ); 

pre-parse : turns ++ ; 

(Handle special cases of input 82 ); 

(Check the clocks and the lamp 178); 

(Handle additional special cases of input 83); 
parse: ( Give advice about going WEST 80 ); 

(Look at wordl and exit to the right place if it completes a command 78); 
shift: strcpy (wordl ,word2); *word2 = ’\0’; goto parse-, 

This code is used in section 75. 

77. ( Global variables 7) += 

motion mot-, /* currently specified motion, if any */ 
action verb ; /* currently specified action, if any */ 

action oldverb-, /* verb before it was changed */ 
object obj-, /* currently specified object, if any */ 
object oldobj; /* former value of obj */ 

wordtype command-type; /* type of word found in hash table */ 
int turns; /* how many times we’ve read your commands */ 


THE MAIN CONTROL LOOP 


Adventure 321 


78. The try-motion macro is often used to end a major cycle, 
^define try-motion (m) { mot = m; goto try-move ; } 

^define stay-put try_mot ion (NOWHERE) 

{ Look at wordl and exit to the right place if it completes a command 78 ) = 
k = lookup (wordl ); 

if (k < 0) { /* Gee, I don’t understand */ 

print/ ( "Sorry , u I u don ’ t u know u the u word u \ "‘/,s\ " . \n" , wordl ); 
goto cycle-, 

} 

branch: command-type = hash-table[k], word-type-, 
switch ( command-type ) { 

case motion-type: try -motion (hash-table[k\. meaning)-, 
case object-type: obj = hash-table [k], meaning-, 

{ Make sure obj is meaningful at the current location 90 ) ; 
if (* word2) break; /* fall through to shift */ 
if (verb) goto transitive-, 

print/ ("What u do u yoUuW8uit u tOudo u with u the u */„s?\n" , wordl ); 
goto cycle; 

case action-type: verb = hash-table[k\. meaning ; 
if (verb = SAY) obj = *word2; 

else if (*word2) break; /* fall through to shift */ 
if (obj) goto transitive; else goto intransitive; 
case message-type: goto speakit; 

} 

This code is used in section 76. 


ABSTAIN =0, §13. 
action = enum, §13. 
action-type = 3, §5. 
hash-table : hash_entry [], §7. 
intransitive: label, §79. 
k: register int, §2. 
listen: void ( ), §72. 
lookup: void ( ), §8. 
meaning: char, §5. 
message-type = 4, §5. 
mot: motion, §19. 
motion =enum, §9. 
motion-type = 1, §5. 

NOTHING =0, §11. 


NOWHERE = 74, §9. 
object =enum, §11. 

object-type = 2, §5. 

print f: int (), <stdio.h>. 

SAY, see §97. 

speakit: label, §79. 

strcpy: char *(), <string.h>. 

transitive: label, §79. 

try-move: label, §75. 

word-type: char, §5. 

wordl : char [], §73. 

word2: char [], §73. 

wordtype = enum, §5. 


322 Selected Papers on Fun and Games 

79. Here is the multiway branch where many kinds of actions can be 
launched. 

If a verb can only be transitive, but no object has been given, we must 
go back and ask for an object. 

If a verb can only be intransitive, but an object has been given, we 
issue the default message for that verb and start over. 

The variable k, initially zero, is used to count various things in several 
of the action routines. 

The report macro is often used to end a minor cycle. 

^define report(m) { printf ('"/.s\n" , m); continue; } 

^define default-to (v) report (default-msg[v\) 

^define change-to(v ) { oldverb = verb ; verb = v; goto transitive ; } 

( Perform an action in the current place 79 } = 
intransitive-, k = 0; 
switch (verb) { 

case GO: case RELAX: goto report-default-, 

case ON: case OFF: case POUR: case FILL: case DRINK: case BLAST: 
case KILL: goto transitive; 

(Handle cases of intransitive verbs and continue 92); 
default: goto get-object; 

} 

transitive : k = 0; 
switch (verb) { 

(Handle cases of transitive verbs and continue 97 ); 
default: goto report-default; 

} 

speakit : report ( message [hash-table [&] . meaning ] ) ; 

report-default: if (default-msg[verb\) report(default-msg[verb ]) else 
continue; 

get-object: wordl [0] = toupper (wordl [0]); 

printf ("’/.SuwhatTSn" , wordl ); goto cycle; 
cantsee-it : if ((verb = FIND V verb = INVENTORY) A *word2 = ’\ 0 ’) 
goto transitive; 

printf (" I u see u no u '/,s u here . \n" , wordl ); continue; 

This code is used in section 75. 

80. Here’s a freely offered hint that may save you typing. 

( Give advice about going WEST 80 ) = 
if (streq (wordl , " west")) { 
if (++ west-count = 10 ) 

printf ( " u If u you u pref er , u simply u type u W u rather u than u WEST. \n" ); 

} 

This code is used in section 76. 


THE MAIN CONTROL LOOP 


Adventure 323 


81. (Global variables 7) += 
int west-count ; 

/* how many times have we parsed the word ‘west’? */ 

82. Maybe you said 'say’ and we said ‘Say what?’ and you replied 
with two things to say. Then we assume you don’t really want us to say 
anything. 

( Handle special cases of input 82 ) = 
if ( verb = SAY) { 

if ( *word2 ) verb = ABSTAIN; else goto transitive ; 

} 

See also section 138. 

This code is used in section 76. 

83. The verb ‘enter’ is listed in our vocabulary as a motion rather 
than an action. Here we deal with cases where you try to use it as an 
action. Notice that ‘H20’ is not a synonym for ‘water’ in this context. 

{ Handle additional special cases of input 83 ) = 
if (streq{wordl , "enter")) { 

if (streq(word2 , "water") V streq(word2, "strea")) { 
if ( water-here ) repor<("Your u feet u are u now u wet . 11 ); 
defaultito (GO) ; 

} 

else if ( *word2 ) goto shift ; 

} 

See also section 105. 

This code is used in section 76. 


ABSTAIN = 0, §13. 

BLAST, see §99. 
cycle : label, §76. 
default-msg: char *[], §15. 
DRINK, see §106. 

FILL, see §110. 

FIND, see §100. 

GO = 9, §13. 

GO, see §79. 

hash-table : hash_entry [], §7. 
INVENTORY, see §94 and §100. 
k : register int, §2. 

KILL, see §125. 
meaning: char, §5. 
message : char *[], §17. 


OFF, see §102. 
oldverb : action, §77. 

ON, see §102. 

POUR, see §107. 

printf : int (), <stdio.h>. 

RELAX = 10, §13. 

RELAX, see §14. 

SAY, see §97. 
shift: label, §76. 
streq = macro ( ), §8. 
toupper: int (), <ctype.h>. 
verb: action, §77. 
water -here — macro, §74. 
wordl : char [], §73. 
word2: char [], §73. 


324 Selected Papers on Fun and Games 

84 . Cavers can become cadavers if they don’t have light. We keep a 
variable was-dark to remember how dark things were when you gave 
your last command. 

^define dark (( flags[loc ] & lighted ) = 0 A (prop [LAMP] = 0 V -i/iere(LAMP))) 

( Global variables 7 ) += 

boolean was-dark ; /* you’ve recently been in the dark */ 

85 . (Make special adjustments before looking at new input 85) = 
was-dark = dark', 

See also sections 158, 169, and 182. 

This code is used in section 76. 

86. After moving to newloc, we act as your eyes. We print the long 
description of newloc if you haven’t been there before; but when you 
return to a previously seen place, we often use a short form. The long 
form is used every 5th time, unless you say ‘BRIEF’, in which case we 
use the shortest form we know. You can always ask for the long form 
by saying ‘LOOK’. 

( Report the current state 86 ) = 
if (loc = limbo) goto death', 
if (dark A -^forced-move (loc)) { 

if (was-dark Apcf(35)) goto pitch-dark', 
p = pitch-dark-msg ; 

} 

else if (short-desc[loc\ = 0 V visits[loc] % interval = 0) p = long-desc[loc ]; 
else p = short-desc[loc ]; 
if (toting (BEAR)) 

printf (" You u ar e u be ing u f ollowed u by u a u very u large , u tame u bear . \n" ); 
printf ("\ n\ 

•/.s\n",p); 

if (forced-move (loc)) goto try-move; 

(Give optional plugh hint 157); 

if (-i dark ) (Describe the objects at this location 88); 

This code is used in section 75. 

87 . ( Global variables 7 ) += 

int interval = 5; /* will change to 10000 if you want us to be BRIEF */ 

char pitch-dark-msg[ ] = "It u is u now u pitch u dark. uu \ 

If u you u proceeduyou u will u most u likely u f all u into u a u pit . " ; 


THE MAIN CONTROL LOOP 


Adventure 325 


88. If TREADS are present but you have a heavy load, we don’t describe 
them. The treads never actually get property value 1; we use the note 
for property 1 only when they are seen from above. 

The global variable tally counts the number of treasures you haven’t 
seen. Another variable, lost-treasures , counts those you never will see. 

( Describe the objects at this location 88 ) = 

{ register object <£; 

visits [loc\ ++ ; 

for (t = first[loc]\ t; t = link[t]) { 
tt = ( base[t ] ? base[t\ : £); 

if ( prop[tt ] < 0) { /* you’ve spotted a treasure */ 

if ( closed ) continue; 

/* no automatic prop change after hours * / 
prop[tt } = (tt = RUG V tt = CHAIM); 

/* initialize the property value */ 
tally — ; 

(Zap the lamp if the remaining treasures are too elusive 183); 

} 

if (tt = TREADS A toting (GOLD)) continue; 
p = note [prop [tt] + offset[tt] + (tt = TREADS A loc = emist)]; 
if (p) printf ("‘/,s\n" ,p); 

} 

} 

This code is used in section 86. 

89. (Global variables 7) += 

int tally = 15; /* treasures awaiting you */ 

int lost-treasures-, /* treasures that you won’t find */ 


base: object [], §63. 

BEAR = 45, §11. 
boolean = enum, §2. 
BRIEF, see §95. 

CHAIN =66, §11. 
closed: boolean, §177. 
death: label, §189. 
emist = 15, §18, §32. 
first: object [], §63. 
flags: int [], §20. 
forced-move = macro ( ), §59. 
GOLD =51, §11. 
here = macro ( ), §74. 

LAMP =2, §11. 
lighted = 1, §20. 
limbo = 0, §18. 
link: object [], §63. 
loc: location, §74. 


long-desc: char *[], §20. 
LOOK =24, §9. 
newloc: location, §74. 
note: char *[], §63. 
object =enum, §11. 
offset: int [], §63. 
p: register char *, §2. 
pet = macro (), §157. 
pitch-dark: label, §188. 
printf : int (), <stdio.h>. 
prop: int [], §63. 

RUG = 63, §11. 
short-desc: char *[], §20. 
t: register object, §68. 
toting = macro ( ), §63. 
TREADS =8, §11. 
try-move: label, §75. 
visits: int [], §20. 


326 Selected Papers on Fun and Games 

90. When you specify an object, it must be at the current location, 
unless the verb is already known to be FIND or INVENTORY. A few other 
special cases also are permitted; for example, water and oil are funny, 
since they are never actually dropped at any location, but they might 
be present inside the bottle or as a feature of the location. 

^define objectAn-bottle 

(( obj = WATER A prop [BOTTLE] S 0 )V(obj = OIL A prop [BOTTLE] = 2)) 

( Make sure obj is meaningful at the current location 90 ) = 
if (-'toting (obj) A -> is-atJoc(obj)) 
switch (obj) { 

case GRATE: (If GRATE is actually a motion word, move to it 91 }; 
goto cantseeAt ; 

case DWARF: if (dflag > 2 A dwarf ()) break; else goto cantseeAt ; 
case PLANT: if ( is.at Joe (PLANT2) A prop [PLANT2]) { 
obj = PLANT2; break; 

} 

else goto cantseeAt; 

case KNIFE: if (loc / knife Joe) goto cantseeAt; 
knife Joe — — 1; 

report ("The u dwarves ’ u knives u vanish u \ 

as u they u strikeuthe u MaIls u of u the u cave . " ); 
case ROD: if (-'here(R0D2)) goto cantseeAt ; 
obj = R0D2; break; 

case WATER: case OIL: if (here (BOTTLE) A objectAn-bottle) break; 

if ((obj = WATER A water -here) V (obj = OIL A oiLhere)) break; 
default : goto cantseeAt ; 

} 

This code is used in section 78. 

91. Henning Makholm has pointed out that the logic here makes GRATE 
a motion word regardless of the verb. For example, you can get to the 
grate by saying ‘wave grate’ from the road or the valley (but curiously 
not from the slit). 

( If GRATE is actually a motion word, move to it 91 ) = 
if ( loc < minJowerJoc) 
switch (loc) { 

case road: case valley: case slit: try- motion (DEPRESSION); 
case cobbles: case debris: case awk: case bird: case spit: 

try-motion (ENTRANCE ) ; 
default: break; 

} 

This code is used in section 90. 


simple verbs Adventure 327 

92. Simple verbs. Let’s get experience implementing the actions 
by dispensing with the easy cases first. 

First there are several “intransitive” verbs that reduce to transitive 
when we identify an appropriate object. For example, ‘take’ makes 
sense by itself if there’s only one possible thing to take. 

( Handle cases of intransitive verbs and continue 92 ) = 

case TAKE: if ( first[loc ] = 0 V link\first[loc\] V dwarf ()) goto get-object-, 

°bj = first[loc]\ goto transitive ; 

case EAT: if (-Aere(FOOD)) goto get-object; 

obj = FOOD; goto transitive-, 

See also sections 93, 94, 95, and 136. 

This code is used in section 79. 


awk = 12, §18, §31. 
bird = 13, §18, §31. 

BOTTLE = 23, §11. 
cantseeJt : label, §79. 
cobbles = 10, §18, §31. 
debris = 11, §18, §31. 
DEPRESSION =32, §9. 
dflag : int, §159. 

DWARF =20, §11. 
dwarf: void (), §160. 

EAT = 12, §13. 

EAT, see §98. 

ENTRANCE = 33, §9. 

FIND, see §100. 
first: object [], §63. 

FOOD =22, §11. 
get-object: label, §79. 

GRATE = 3, §11. 
here = macro (), §74. 
INVENTORY, see §94 and §100. 
is-atJoc: void (), §66. 

KNIFE = 21, §11. 
knifeJoc: int, §168. 


link: object [], §63. 
loc: location, §74. 
mindowerdoc = 15, §18. 
obj: object, §77. 

OIL = 25, §11. 
oiLhere = macro, §74. 
PLANT =28, §11. 

PLANT2 = 29, §11. 
prop: int [], §63. 
report = macro ( ), §79. 
road = 1 , §18, §23. 

ROD =6, §11. 

R0D2 = 7, §11. 
slit =7, §18, §28. 
spit = 14, §18, §31. 

TAKE = 1, §13. 

TAKE, see §112. 
toting = macro ( ), §63. 
transitive: label, §79. 
try-motion = macro (), §78. 
valley = 4, §18, §26. 

WATER = 24, §11. 
water-here - macro, §74. 


328 Selected Papers on Fun and Games 

93. Only the objects GRATE, DOOR, CLAM/OYSTER, and CHAIN can be 
opened or closed. And only a few objects can be read. 

( Handle cases of intransitive verbs and continue 92 ) += 
case OPEN: case CLOSE: if (place [GRATE] = loc V place [GRATE_] = loc) 
obj = GRATE; 

else if (place [DOOR] = loc) obj = DOOR; 
else if (here (CLAM)) obj = CLAM; 
else if (here (OYSTER)) obj = OYSTER; 
if (here (CHAIN)) { 

if (obj) goto get.object', else obj = CHAIN; 

} 

if (obj) goto transitive ; 

repori("There LJ is u nothing u here u with u a u lock! " ); 

case READ: if (dark) goto get.object ; /* can’t read in the dark */ 

if (Aere(MAG)) obj — MAG; 
if (here (TABLET)) { 

if (obj) goto get.object ; else obj = TABLET; 

} 

if (ftere(MESSAGE)) { 

if (obj) goto get.object ; else obj = MESSAGE; 

} 

if (closed A toeing (OYSTER)) obj = OYSTER; 
if (obj) goto transitive ; else goto get.object ; 

94. A request for an inventory is pretty simple too. 

( Handle cases of intransitive verbs and continue 92 ) += 
case INVENTORY: for (t = 1; t < max.obj-, t++) 

if (toting (t) A (base[t\ = NOTHING V base[t] = t) A t / BEAR) { 
if (k = 0) 

k = 1, pnnf/("You u are u currently u holding u the u following: \n" ); 
printf (" u "/.s\n", name[t])‘, 

} 

if (toting (BEAK)) 

report ("You u are u being u f ollowed u by u a u very u large , u tame u bear . " ); 
if (k = 0) report ("You’re u not u carrying u anything. " ); 
continue; 


SIMPLE VERBS 


Adventure 329 


95. Here are other requests about the mechanics of the game. 

( Handle cases of intransitive verbs and continue 92 } += 

case BRIEF : interval = 10000; 
look-count = 3; 

report ( " Okay , u f r om u now u on u \ 

I ’lluonly u describe u a u place u in u full u the u f irst u time\n\ 
you u come u to u it . uu To u get u the u full u description, u say u \"LOOK\" . " ); 
case SCORE: printf ("If u you u were u to u quit u now, u you u would u score u "/.d\n\ 
out u of u a u possible u ’/,d. \n" , score( ) — 4, maxscore); 
if ( _l J/es( "Do u you u indeed u wish u to u quit u now?" , ok, ok)) continue; 
goto give.up; 

case QUIT: if (-i?/es("Do u you u really u wish u to u quit u now?" , ok, ok)) 
continue; 

give-up: gave.up = true; goto quit; 

96. (Global variables 7) += 

boolean gave.up; /* did you quit while you were alive? */ 


base : object [], §63. 
BEAR = 45, §11. 
boolean =enum, §2. 
BRIEF = 25, §13. 

CHAIN =66, §11. 

CLAM = 17, §11. 

CLOSE = 4, §13. 

CLOSE, see §130. 
closed: boolean, §177. 
dark = macro, §84. 
DOOR = 11, §11. 
get-object: label, §79. 
GRATE =3, §11. 

GRATE_ =4, §11. 
here = macro ( ), §74. 
interval: int, §87. 
INVENTORY = 27, §13. 
INVENTORY, see §100. 
k: register int, §2. 
loc: location, §74. 
look-count: int, §142. 
MAG = 19, §11. 
max-obj =66, §11. 
max^s core = 350, §193. 


MESSAGE =46, §11. 
name: char *[], §63. 
NOTHING =0, §11. 
obj: object, §77. 
ok = macro, §14. 

OPEN = 3, §13. 

OPEN, see §130. 

OYSTER = 18, §11. 
place: location [], §63. 
printf: int (), <stdio.h>. 
quit: label, §2. 

QUIT = 29, §13. 

READ = 23, §13. 

READ, see §135. 
report = macro ( ), §79. 
score: void (), §197. 

SCORE =28, §13. 
t: register object, §68. 
TABLET = 16, §11. 
toting = macro ( ), §63. 
transitive: label, §79. 
true = 1, §2. 
yes: void ( ), §71. 


330 Selected Papers on Fun and Games 

97. The SAY routine is just an echo unless you say a magic word. 
(Handle cases of transitive verbs and continue 97 ) = 

case SAY: if ( *word2 ) strcpy (wordl ,word2); 
k = lookup (wordl ); 
switch (hash-table [k]. meaning) { 
case FEEFIE: 

if (hash-table[k\. word-type ^ action-type) break; 
case XYZZY: case PLUGH: case PLOVER: 

*word2 = ’\0’; obj = NOTHING; goto branch; 
default: break; 

} 

printf (" Okay , u \" 7 .s\" . \n" , wordl ); continue; 

See also sections 98, 99, 100, 101, 102, 106, 107, 110, 112, 117, 122, 125, 129, 130, 
and 135. 

This code is used in section 79. 

98. Hungry? 

( Handle cases of transitive verbs and continue 97 ) += 
case EAT: switch (obj) { 
case FOOD: destroy (FOOD); 

report ("Thank u you, u it u was u delicious ! " ); 
case BIRD: case SNAKE: case CLAM: case OYSTER: case DWARF: 
case DRAGON: case TROLL: case BEAR: 
report("I u think u I u just u lost u my u appetite. " ); 
default: goto report-default; /* see §14 for default-ms g[Ekl] */ 

} 

99. Waving to the shadowy figure has no effect; but you might wave 
a rod at the fissure. Blasting has no effect unless you’ve got dynamite, 
which is a neat trick! Rubbing yields only snide remarks. 

( Handle cases of transitive verbs and continue 97 ) += 
case WAVE: if ( obj / ROD V (loc 7 ^ efiss A loc / wfiss) V 
^toting (obj) V closing) { 

if (toting(obj) V (obj = ROD A toting( R0D2))) goto report-default; 
default-to (DROP ) ; 

} 

prop [CRYSTAL] = 1 - prop [CRYSTAL]; 

report (note [offset [CRYSTAL] + 2 — prop[CRYSTAL]]); 

case BLAST: if (closed A prop [R0D2] > 0) { 

bonus = (Aere(R0D2) ? 25 : loc = neend ? 30 : 45); 
printf ("'/,s\n" , message[bonus /5]); goto quit; 

} 

else goto report-default; 
case RUB: if (obj = LAMP) goto report-default; 


SIMPLE VERBS 


Adventure 331 


default-to( TOSS); 

100. If asked to find an object that isn’t visible, we give a caveat. 
(Handle cases of transitive verbs and continue 97 ) += 
case FIND: case INVENTORY: if (toting (obj)) default-to (TAKE ) ; 
if ( closed ) 

report ("I u daresay u whatever u you u want u is u around u here u somewhere . " ) 

if (is -at Joe (obj) V (object-in-bottle A place [BOTTLE] = loc) V 
(obj = WATER A water -here) V (obj = OIL A oiLhere) V 
(obj = DWARF A dwarf ( ))) 

report ("I u believe u what u youuwant u is u rightuhere u with u you. " ); 
goto report-default ; 


action-type = 3, §5. 

BEAR =45, §11. 

BIRD = 10, §11. 

BLAST = 20, §13. 
bonus: int, §193. 

BOTTLE = 23, §11. 
branch: label, §78. 

CLAM = 17, §11. 
closed: boolean, §177. 
closing = macro, §177. 

CRYSTAL = 14, §11. 
default-msg: char *[], §15. 
default-to = macro ( ), §79. 
destroy = macro ( ), §65. 
DRAGON =37, §11. 

DROP, see §117. 

DWARF =20, §11. 
dwarf: void (), §160. 

EAT = 12, §13. 

EAT, see §92. 
efiss = 17, §18, §34. 

FEEFIE = 24, §13. 

FEEFIE, see §136. 

FIND = 26, §13. 

FOOD = 22, §11. 

hash-table: hash-entry [], §7. 
here = macro ( ), §74. 
INVENTORY = 27, §13. 
INVENTORY, see §94. 
is-at-loc: void (), §66. 
k: register int. §2. 

LAMP =2, §11. 
loc: location, §74. 
lookup: void (), §8. 
meaning: char, §5. 
message: char *[], §17. 


neend = 127, §18, §58. 
note: char *[], §63. 

NOTHING =0, §11. 
obj : object , §77. 
object-in-bottle = macro, §90. 
offset: int [], §63. 

OIL = 25, §11. 
oil-here = macro, §74. 

OYSTER = 18, §11.' 
place: location [], §63. 

PLOVER = 72, §9. 

PLUGH = 71, §9. 

printf: int (), <stdio.h>. 

prop: int [], §63. 

quit: label, §2. 

report = macro (), §79. 

report-default: label, §79. 

ROD = 6, §11. 

R0D2 = 7, §11. 

RUB = 14, §13. 

SAY = 22, §13. 

SNAKE = 13, §11. 

strepy: char *(), <string.h>. 

TAKE, see §92 and §112. 

TOSS, see §122. 
toting = macro ( ), §63. 

TROLL =41, §11. 

WATER = 24, §11. 
water-here — macro, §74. 

WAVE = 7, §13. 
wfiss = 18, §18, §34. 
word-type: char, §5. 
wordl: char [], §73. 
word2 : char [], §73. 

XYZZY = 70, §9. 


332 Selected Papers on Fun and Games 

101 . Breaking and/or waking have no effect until the cave is closed, 
except of course that you might break the vase. The dwarves like mirrors 
and hate being awakened. 

( Handle cases of transitive verbs and continue 97 ) += 
case BREAK: if ( obj = VASE A prop [VASE] e0) { 

if (toting (\ kSE)) drop (VASE, loc); /* crash */ 
printf ("You u have u taken u the u vase u \ 

and u hurled u it u delicately u to u the u groimd. \n" ); 
smash: prop [VASE] = 2; base [VASE] = VASE; continue; 

/* it’s no longer movable */ 

} 

else if ( obj / MIRROR) goto report-default ; 
if ( closed ) { 

printf ("YoUuStrike u the u mirror u a u resounding u blow, u \ 
whereupon u it u shatters u into u a\n\ 
myriad u tiny u fragmeiits . " ); goto dwarves-upset ; 

} 

report ("It u is u too u f ar u up u f or u you u to u reach. " ); 
case WAKE: if ( closed A obj = DWARF) { 

printf ("You u prod u the u nearest u dwarf )U \ 

who u wakes u up u grumpily , u takes u one,jlook u at\n\ 
you, u curses, u and u grabsufor u his u axe.\n"); goto dwarves-upset; 

} 

else goto report-default; 

102 . Here we deal with lighting or extinguishing the lamp. The vari- 
able limit tells how much juice you’ve got left. 

{ Handle cases of transitive verbs and continue 97 ) += 
case ON: if (-<here (LAMP)) goto report-default; 

if ( limit < 0) report ("Your u lamp u has u run u out u of u power ." ); 
prop [LAMP] = 1; 

printf ( " Your u lamp u is u now u on . \n" ); 
if ( was-dark ) goto commence; 
continue; 

case OFF: if (~<here( LAMP)) goto report-default; 
prop [LAMP] = 0; 

printf ("Your u lamp u is u now u off . \n" ); 
if (dark) printf ("‘/.s\n" , pitch-dark-msg); 

continue; 

103 . (Global variables 7) += 

int limit; /* countdown till darkness */ 


LIQUID ASSETS 


Adventure 333 


104. Liquid assets. Readers of this program will already have no- 
ticed that the BOTTLE is a rather complicated object, since it can be 
empty or filled with either water or oil. Let’s consider now the main 
actions that involve liquids. 

When you are carrying a bottle full of water, place [WATER] will be 
inhand-, hence both toting (WATER) and toting (BOTTLE) are true. A 
similar remark applies to a bottle full of oil. 

The value of prop [BOTTLE] is 0 if it holds water, 2 if it holds oil, 
otherwise either 1 or —2. (The value —2 is used after closing the cave.) 
#define bottle-empty {prop [BOTTLE] slV prop [BOTTLE] < 0) 

105. Sometimes ‘water’ and ‘oil’ are used as verbs. 

( Handle additional special cases of input 83 ) += 
if {{streq{wordl , "water") V streq{wordl , "oil")) A 

(streq{word2 , "plant") V streq (word2 , "door")) A 
( loc = place[hash-table[lookup(word2)]. meaning])) 
strcpy {word2 , "pour"); 


base : object [], §63. 

BOTTLE = 23, §11. 

BREAK =19, §13. 
closed: boolean, §177. 
commence : label, §75. 
dark = macro, §84. 
drop: void (), §64. 

DWARF = 20, §11. 
dwarves -up set: label, §192. 
hash-table: hash-entry [], §7. 
here = macro ( ), §74. 
inhand = — 1, §18. 

LAMP = 2, §11. 
loc: location, §74. 
lookup: void (), §8. 
meaning: char, §5. 

MIRROR = 26, §11. 
obj: object, §77. 


OFF =6, §13. 

ON = 5, §13. 

pitch-dark-ms g : char [], §87. 
place: location [], §63. 
print}: int (), <stdio.h>. 
prop: int [], §63. 
report = macro ( ), §79. 
report-default: label, §79. 
strcpy: char *(), <string.h>. 
streq = macro ( ), §8. 
toting = macro ( ), §63. 

VASE = 59, §11. 

WAKE = 16, §13. 
was-dark: boolean, §84. 

WATER = 24, §11. 
wordl: char [], §73. 
wordS: char [], §73. 


334 Selected Papers on Fun and Games 

106. If you ask simply to drink, we assume that you want water. If 
there’s water in the bottle, you drink that; otherwise you must be at a 
water location. 

(Handle cases of transitive verbs and continue 97 ) += 
case DRINK: if ( obj = NOTHING) { 

if (~<water-here A -'(feere (BOTTLE) A prop [BOTTLE] =0)) goto get-object ; 

} 

else if ( obj ^ WATER) default-to( EAT); 

if (~>(here (BOTTLE) A prop [BOTTLE] =0)) goto report-default ; 

prop [BOTTLE] = 1; place [WATER] = limbo ; 

report ("The u bottle u of u Mater u is u now u empty. " ); 

107. Pouring involves liquid from the bottle. 

(Handle cases of transitive verbs and continue 97) += 
case POUR: if (obj = NOTHING V obj = BOTTLE) { 

obj = (prop [BOTTLE] = 0 ? WATER : prop [BOTTLE] = 2 ? OIL : 0); 
if (obj = NOTHING) goto get-object-, 

} 

if (-itoting (obj)) goto report-default-, 

if (obj 7 ^ WATER A obj ^ OIL) report ("You u can’ t u pour u that ." ); 

prop[B0TTLE] = 1; place[obj] = limbo-, 

if (loc = place [PLANT]) (Try to water the plant los); 

if (loc = place [DOOR]) (Pour water or oil on the door 109 ); 

report ("Your u bottle u isuempty u and u theuground u is u wet . " ); 

108. ( Try to water the plant 108 ) s 

{ 

if (obj ^ WATER) 

report ("The u plant u indignantly u shakes u the u oil u of f u its u leaves u \ 
and u asks, u \"Water?\" " ); 

printf ("'/,s\n" , note [prop [PLANT] + 1 + offset [PLANT]]); 
prop [PLANT] += 2; if (prop [PLANT] > 4) prop [PLANT] = 0; 
prop [PLANT2] = prop [PLANT] 1; 
stay-put ; 

} 

This code is used in section 107. 


LIQUID ASSETS 


Adventure 335 


109. ( Pour water or oil on the door 109 ) = 
switch ( obj ) { 

case WATER: prop [DOOR] = 0; 

report ( "The u hinges u are u quite u thoroughly u rusted u now u \ 
and u won ’ t u budge . " ) ; 
case OIL: prop [DOOR] = 1; 

report ("The u oil u hasufreed u up u theuhingesu\ 
so u that u the u door u will u now u open. " ); 

This code is used in section 107. 

110. You can fill the bottle only when it’s empty and liquid is available. 
You can’t fill the lamp with oil. 

(Handle cases of transitive verbs and continue 97 ) -)-= 
case FILL: if ( obj = VASE) (Try to fill the vase ill); 
if (^here (BOTTLE)) { 

if ( obj = NOTHING) goto get-object; else goto report-default ; 

else if ( obj ± NOTHING A obj # BOTTLE) goto report-default; 
if (-> bottle-empty ) report ("Yourubottle u is u already u full ); 
if ( noJiquid-here ) 

report ("There u isunothing u here u withuwhichuto u fill u theubottle."); 

prop [BOTTLE] = flags [loc] & oil ; 

if ( toting (BOTTLE ) ) place [prop [BOTTLE] ? OIL : WATER] = inhand; 
printf ("Your u bottle u is u now u full u of u , /.s.\n", 
prop [BOTTLE] ? "oil" : "water"); 
continue; 


BOTTLE = 23, §11. 
bottle-empty = macro, §104. 
default-to — macro (), §79. 
DOOR = 11, §11. 

DRINK = 13, §13. 

EAT, see §92 and §98. 

FILL = 18, §13. 
flags : int [], §20. 
get-object: label, §79. 
here = macro ( ), §74. 
inhand = — 1, §18. 
limbo = 0, §18. 
loc: location, §74. 
no-liquid-here = macro, §74. 
note: char *[], §63. 
NOTHING =0, §11. 
obj: object, §77. 


offset: int [], §63. 

OIL = 25, §11. 
oil = 2, §20. 

place: location [], §63. 
PLANT = 28, §11. 

PLANT2 =29, §11. 

POUR = 11, §13. 
printf: int (), <stdio.h>. 
prop: int [], §63. 
report = macro ( ), §79. 
report-default: label, §79. 
stay-put = macro, §78. 
toting = macro (), §63. 
VASE = 59, §11. 

WATER = 24, §11. 
water-here = macro, §74. 


336 Selected Papers on Fun and Games 

111 . Filling the vase is a nasty business. 

(Try to fill the vase ill) = 

{ 

if ( noJiquid-here ) 

report("There u is u nothing u here u with u which u to u f ill u the u vase . \n" ); 
if (-^toting (VASE)) report (default-msg [DROP]); 
printf ("The u sudden u change u inutemperature u has u \ 
delicately u shattered u the u vase . \n" ); 
goto smash ; 

} 

This code is used in section 110. 

112 . Picking up a liquid depends, of course, on the status of the bottle. 
Other objects need special handling, too, because of various side effects 
and the fact that we can’t take bird and cage separately when the bird 
is in the cage. 

(Handle cases of transitive verbs and continue 97 ) += 
case TAKE: if (toting (obj)) goto report-default ; 

/* already carrying it */ 
if (6ase[o6)]) { /* it is immovable */ 

if ( obj = CHAIN A prop [BEAR]) report ("The u chain u is u still u locked ." ); 
if ( obj = BEAR A prop [BEAR] = 1) 

report("The u bear u is u still u chained u to u the u wall. " ); 
if ( obj = PLANT A prop [PLANT] < 0) 

report ("The u plant u has u exceptionally u deep u roots u \ 
cUid u cannot u be u pulled u f ree . " ); 
report ("You u can’ t u be u serious ! " ); 

} 

if ( obj = WATER V obj = OIL) (Check special cases for taking a liquid 113 ); 
if ( holding >7) report ("You u can’ t u carry u anything u more . uu \ 
You’ll u have u to u drop u something u f irst . " ); 
if ( obj = BIRD A prop [BIRD] = 0) 

(Check special cases for taking a bird 114 ); 
if ( obj = BIRD V ( obj = CAGE A prop[BIRD])) carry ( BIRD + CAGE — obj); 
carry (obj); 

if ( obj = BOTTLE A -^bottle -empty) 

place [prop [BOTTLE] ? OIL : WATER] = inhand; 
default-to (RELAX); /* OK, we’ve taken it =t=/ 


LIQUID ASSETS 


Adventure 337 


113. (Check special cases for taking a liquid 113 ) s 
if (here (BOTTLE) A object-in-bottle) obj = BOTTLE; 
else { 

obj = BOTTLE; 

if (toting (BOTTLE)) change-to( FILL); 

report ("You u have u nothing u in u which u to u carry u it . " ); 

This code is used in section 112. 

114. (Check special cases for taking a bird 114 } = 

{ 

if (toting (ROD)) 

report ( "The u bird u was u unaf raid u when u you u entered , u \ 
but u as u you u approach u it u becomes\n\ 
disturbed u and u you u cannot u catch u it . " ); 
if (toting (CAGE)) prop[BIRD] = 1; 

else report ("YouuCan u catchutheubird, u butuyou u cannot u carry u it . " ); 

This code is used in section 112. 

115. Similarly, when dropping the bottle we must drop also its liquid 

contents, if any. 

( Check special cases for dropping a liquid 115 ) = 
if (object-in-bottle) obj = BOTTLE; 
if (obj = BOTTLE A bottle-empty ) 

place [prop [BOTTLE] ? OIL : WATER] = limbo-, 

This code is used in section 117. 


base: object [], §63. 

BEAR = 45, §11. 

BIRD = 10, §11. 

BOTTLE = 23, §11. 
bottle-empty = macro, §104. 
CAGE =5, §11. 
carry: void (), §65. 

CHAIN =66, §11. 
change-to = macro (), §79. 
default-msg: char *[], §15. 
default-to = macro ( ), §79. 
DROP, see §117. 

FILL = 18, §13. 
here = macro ( ), §74. 
holding: int, §63. 
inhand = — 1, §18. 
limbo = 0, §18. 
no-liquid-here = macro, §74. 


obj: object, §77. 

object-in-bottle = macro, §90. 

OIL = 25, §11. 

place: location [], §63. 

PLANT = 28, §11. 

printf: int (), <stdio.h>. 

prop: int [], §63. 

RELAX, see §14 and §79. 
report = macro ( ), §79. 
report-default: label, §79. 
ROD = 6, §11. 
smash: label, §101. 

TAKE = 1, §13. 

TAKE, see §92. 
toting = macro ( ), §63. 

VASE = 59, §11. 

WATER = 24, §11. 


338 Selected Papers on Fun and Games 

116. The other actions. Now that we understand how to write 
action routines, we’re ready to complete the set. 

117. Dropping an object has special cases for the bird (which might 
attack the snake or the dragon), the cage, the vase, etc. The verb TOSS 
also reduces to DROP for most objects. 

(The term PONY is a nod to the vending machine once installed in a 
room called The Prancing Pony, part of Stanford’s historic AI Labora- 
tory.) 

( Handle cases of transitive verbs and continue 97 ) += 
case DROP: if ( obj = ROD A toting) R0D2) A -^toting) ROD)) obj = R0D2; 
if (-itoting [obj)) goto report-default ; 

if ( obj = COINS A here(PONY)) (Put coins in the vending machine lis); 
if ( obj = BIRD) (Check special cases for dropping the bird 120 ); 
if (obj = VASE A loc / soft) 

( Check special cases for dropping the vase 121 ); 
if ( obj = BEAR A is-atJoc (TROLL)) (Chase the troll away 119); 

(Check special cases for dropping a liquid 115); 
if (obj = BIRD) prop[BIRD] = 0; 
else if (obj = CAGE A prop [BIRD]) drop (blKD Joe)-, 
drop (obj , loc)-, 

if (k) continue; else default-to( RELAX); 

118. (Put coins in the vending machine 118) = 

{ 

destro y (COINS); 

drop (BATTERIES , loc ) ; 

prop [BATTERIES] = 0; 

report (note [offset [BATTERIES]] ) ; 

} 

This code is used in section 117. 

119. TR0LL2 is the absent troll. We move the troll bridge up to first 
in the list of things at its location. 

(Chase the troll away 119 ) = 

{ 

printf ("The u bear u lumbers u toward u the u troll , u \ 

who u lets u out u a u startled u shriek u and\n\ 
scurries u away . uu The u bear u soon u gives u up u the u pursuit u \ 
and u wanders u back . \n" ); 

k = 1; /* suppress the “OK” message */ 

destroy) TROLL); destroy (TR0LL_); 
drop (TR0LL2 , swside ) ; drop (TR0LL2_ , neside ) ; 
prop [TROLL] = 2; 


THE OTHER ACTIONS 


Adventure 339 


move ( BRIDGE , swside ) ; move (BRIDGE. , neside ) ; 

/* put first in their lists */ 

} 

This code is used in section 117. 

120. (Check special cases for dropping the bird 120 ) = 

{ 

if (here (SNAKE)) { 

printf ("The u little u bird u attacks u the u green u snake , u \ 
and u in u an u as t ounding u f lur r y \n \ 
drives u the u snake u away . \n" ); k = 1; 

if ( closed ) goto dwarves-upset ; 
destroy (SNAKE); 

prop [SNAKE] = 1; /* used in conditional instructions */ 

} 

else if ( is-atJoc (DRAGON ) A prop [DRAGON] SO) { 
destroy (BIRD); prop [BIRD] = 0; 
if (place [SNAKE] = hmk ) lost-treasures ++; 
report ( "The u little u bird u attacks u the u green u dragon , u \ 
and u in u an u ast ounding u f lurry\n\ 
gets u burnt u to u a u cinder . uuTbeu a shes (J blow u away . " ) : 

} 

This code is used in section 117. 


BATTERIES = 49, §11. 

BEAR = 45, §11. 

BIRD = 10, §11. 

BRIDGE = 39, §11. 

BRIDGE. =40, §11. 

CAGE = 5, §11. 
closed: boolean, §177. 
COINS =55, §11. 
default-to = macro ( ), §79. 
destroy = macro ( ), §65. 
DRAGON = 37, §11. 
drop: void (), §64. 

DROP =2, §13. 
dwarves-upset : label, §192. 
here = macro ( ), §74. 
hmk = 50, §18, §40. 
is-atJoc: void (), §66. 
k: register int, §2. 
loc: location, §74. 
lost-treasures: int, §89. 
move = macro (), §65. 
neside = 118, §18, §57. 


note: char *[], §63. 
obj: object, §77. 
offset: int [], §63. 
place: location [], §63. 
PONY = 48, §11. 
printf: int (), <stdio.h>. 
prop: int [], §63. 

RELAX, see §14 and §79. 
report = macro ( ), §79. 
report-default: label, §79. 
ROD =6, §11. 

R0D2 = 7, §11. 

SNAKE = 13, §11. 
soft = 70, §18, §45. 
swside = 105, §18, §55. 
toting = macro ( ), §63. 
TROLL = 41, §11. 

TR0LL_ =42, §11. 

TR0LL2 =43, §11. 

TR0LL2_ =44, §11. 

VASE = 59, §11. 


340 Selected Papers on Fun and Games 


121. ( Check special cases for dropping the vase 121 ) = 

{ 

prop [VASE] = (place [PILLOW] = loci 0 : 2); 

printf ('"/, s\n" , note [offset [VASE] + 1 + prop [VASE]]); k = 1; 

if (prop [VASE]) 6ase[VASE] = VASE; 

} 

This code is used in section 117. 

122. Throwing is like dropping, except that it covers a few more cases. 

( Handle cases of transitive verbs and continue 97 } += 
case TOSS: if (obj = ROD A toting( R0D2) A ->toting( ROD)) obj = R0D2; 
if (~\toting (obj)) goto report-default ; 

if (is -treasure (obj) A is-at-loc (TROLL)) (Snarf a treasure for the troll 124 } 
if (obj = FOOD A here (BEAR)) { 
obj = BEAR; change-to (FEED); 

} 

if (obj / AXE) change-to (DROP); 
if (dwarf ()) (Throw the axe at a dwarf 163); 
if (is-atJoc (DRAGON) A prop [DRAGON] = 0) 
printf ("The u axe u bomices u harmlessly u \ 

of f u the u dragon’ s u thick u scales . \n" ); 
else if (is-at-loc (TROLL)) 

printf ("The u troll u deftly u catches u the u axe , u \ 

examines u it u carefully , u and u tosses u it\n\ 
back , u declar ing , u \ " Good u workmanship , u \ 
but u it ’ s u not u valuable u enough . \"\n" ); 
else if (here (BEAR) A prop [BEAR] = 0) (Throw the axe at the bear 123 ) 
else { 

obj = NOTHING; 
change-to (KILL ) ; 

} 

drop (AXE, loc)\ stay-put ; 

123. This’ll teach you a lesson. 

( Throw the axe at the bear 123 ) = 

{ 

drop (AXE, /oc); 

prop [AXE] = 1; base [AXE] = AXE; /* it becomes immovable */ 
if (place [BEAR] = loc) move (BEAR, toe); 

/* put bear first in its list */ 
report ("The u axe u misses u cind u lands u near u the u bear u \ 
where u you u can ’ t u get u at u it . " ) ; 

} 

This code is used in section 122. 


the other actions Adventure 341 

124. If you toss the vase, the skillful troll will catch it before it breaks. 
{Snarf a treasure for the troll 124) = 

{ 

drop(obj , limbo); 

destroy (TROLL); destroy (TROLL,); 
drop (TR0LL2, swside ); drop (TR0LL2_, neside ); 
move (BRIDGE , swside ) ; move (BRIDGE, , neside ) ; 
report ("The u troll u catches u your u treasure u \ 

and u scurries u away u out u of u sight . " ); 

} 

This code is used in section 122. 


AXE =34, §11. 
base: object [], §63. 

BEAR = 45, §11. 

BRIDGE =39, §11. 

BRIDGE. =40, §11. 
change-to = macro (), §79. 
destroy = macro ( ), §65. 
DRAGON =37, §11. 
drop: void (), §64. 

DROP, see §117. 
dwarf : void (), §160. 
FEED, see §129. 

FOOD = 22, §11. 
here = macro ( ), §74. 
is-at-loc: void (), §66. 
is-treasure = macro ( ) , §11. 
k: register int, §2. 

KILL, see §125. 
limbo = 0, §18. 
loc: location, §74. 
move = macro ( ), §65. 
neside = 118, §18, §57. 


note: char *[], §63. 
NOTHING =0, §11. 
obj: object, §77. 
offset: int [], §63. 

PILLOW = 12, §11. 
place: location [], §63. 
printf : int (), <stdio.h>. 
prop: int [], §63. 
report = macro ( ), §79. 
report-default: label, §79. 
ROD = 6, §11. 

R0D2 = 7, §11. 
stay-put = macro, §78. 
swside = 105, §18, §55. 
TOSS = 15, §13. 
toting = macro ( ), §63. 
TROLL =41, §11. 

TROLL, =42, §11. 

TROLL 2 =43, §11. 

TR0LL2, =44, §11. 

VASE = 59, §11. 


342 Selected Papers on Fun and Games 

125. When you try to attack, the action becomes violent. 

( Handle cases of transitive verbs and continue 97 } += 

case KILL: if ( obj = NOTHING) (See if there’s a unique object to attack 126 ) 
switch ( obj ) { 

case 0: report ("Thereuis u nothing u here u to u attack. " ); 
case BIRD: (Dispatch the poor bird 127); 

case DRAGON: if (prop [DRAGON] = 0) (Fun stuff for dragon 128 ); 
cry. 

report ( "For u cry ing u out u loud , u the u poor u thinguis u already u dead ! " ) ; 
case CLAM: case OYSTER: 

report ( "The u shell u isuvery u strong u and u impervious u to u attack. " ); 
case SNAKE: report ("Attacking u theusnake u both u doesn't u work u \ 
and u is u very u dangerous . " ); 
case DWARF: if ( closed ) goto dwarves-upset ; 

report ("With u what? uu Your u bare u hands?" ); 
case TROLL: report ("Trolls u are u close u relatives u with u the u rocks u \ 
and u have u skin u as u t ough u as \n \ 
a u rhinoceros u hide . uu \ 

The u troll u f ends u of f u your u blows u ef f ortlessly . " ); 
case BEAR: switch (prop [BEAR]) { 

case 0: report ("With u what? uu Your u bare u haiids? uu \ 
Against u HIS u bear u hands?" ); 
case 3: goto cry ; 

default : report ("The u bear u is u conf used ; u \ 

he u only u wants u to u be u your u friend. " ); 

} 

default : goto report-default ; 

} 


THE OTHER actions Adventure 343 

126. Attackable objects fall into two categories: enemies (snake, 
dwarf, etc.) and others (bird, clam). 

We might get here when you threw an axe; you can’t attack the bird 
with an axe. 

( See if there’s a unique object to attack 126 ) = 

{ 

if (dwarf ()) k++,obj = DWARF; 
if (here( SNAKE)) k++,obj = SNAKE; 

if (is_atJoc(DRAGON) A prop [DRAGON] = 0) k++, obj = DRAGON; 
if ( is-atJoc (TROLL ) ) k++, obj = TROLL; 
if (here( BEAR) A prop[BEAR] = 0) k++, obj = BEAR; 
if (k = 0) { /* no enemies present */ 

if (Ziere(BIRD) A oldverb ^ TOSS) k++, obj = BIRD; 
if (Ziere(CLAM) V here (OYSTER)) k ++ , obj = CLAM; 

/* no harm done to call the oyster a clam in this case */ 

} 

if (k > 1) goto get-object ; 

} 

This code is used in section 125. 

127. (Dispatch the poor bird 127) = 

{ . 

if ( closed ) report ("Oh, u leave u the u poor u mihappy u bird u alone . " ); 

destroy (BIRD); prop [BIRD] = 0; 

if (place [SNAKE] = hmk ) lost-treasures ++; 

report ("The u little u bird u is u now u dead. uu Its u body u disappears . " ); 

} 

This code is used in section 125. 


BEAR = 45, §11. 

BIRD = 10, §11. 

CLAM = 17, §11. 
closed : boolean, §177. 
destroy = macro ( ), §65. 
DRAGON =37, §11. 

DWARF =20, §11. 
dwarf: void (), §160. 
dwarves -up set: label, §192. 
get-object: label, §79. 
here = macro ( ), §74. 
hmk = 50, §18, §40. 
is-at-loc: void (), §66. 
k: register int, §2. 


KILL =21, §13. 
lost-treasures: int, §89. 
NOTHING =0, §11. 
obj : object , §77. 
oldverb: action, §77. 
OYSTER = 18, §11.' 
place: location [], §63. 
prop: int [], §63. 
report = macro ( ), §79. 
report-default: label, §79. 
SNAKE = 13, §11. 

TOSS, see §122. 

TROLL =41, §11. 


344 Selected Papers on Fun and Games 

128. Here we impersonate the main dialog loop. If you insist on 
attacking the dragon, you win! He dies, the Persian rug becomes free, 
and scan2 takes the place of scanl and scan3 . 

( Fun stuff for dragon 128 ) = 

{ 

printf ("With u what? uu Y our ubare u hands?\n" ); 
verb = ABSTAIN; obj = NOTHING; 

listen ( ); 

if (~^(streq(wordl , "yes" ) V streq(wordl , "y" ))) goto pre-parse\ 
printf ( "7,s\n" , note [offset [DRAGON] + 1]); 
prop [DRAGON] = 2; /* dead */ 

prop [RUG] = 0; base [RUG] = NOTHING; 

/* now it’s a usable treasure */ 
base [DRAGON.] = DRAGON.; 
destroy (DRAGON.); /* inaccessible */ 
base [RUG.] = RUG.; 

destroy (RUG.); /* inaccessible */ 

for (t = 1; t < max-obj; t++) 

if (place [t] = scanl V place [£] = scan3) move(t, scan2)\ 
loc = scan2\ stay-put ; 

} 

This code is used in section 125. 

129. Feeding various animals leads to various quips. Feeding a dwarf 
is a baaaaad idea. The bear is special. 

(Handle cases of transitive verbs and continue 97} += 
case FEED: switch (obj) { 
case BIRD: 

report ( " It ’ s u not u hungry u ( it ’ s u mer ely u pinin ’ u f or u the u f j or ds ) . uu \ 
Besides , u you\n\ 
have u no u bird u seed. " ); 

case TROLL: report ("Gluttony u is u not u one u of u the u troll ’ s u vices . uu \ 
Avarice , u however , u is . " ) ; 

case DRAGON: if (prop [DRAGON]) report ( default-msg [EAT] ) ; 
break; 

case SNAKE: if (closed V -'here (BIRD)) break; 
destroy (BIRD); prop [BIRD] = 0; lost-treasures ++; 
report("The u snake Ll has u now u devoured u your u bird. " ); 
case BEAR: if (->/iere(F00D)) { 
if (prop [BEAR] = 0) break; 
if (prop [BEAR] = 3) change-to (EAT); 
goto report-default-, 

} 

destroy) FOOD); prop [BEAR] = 1; 


THE OTHER ACTIONS 


Adventure 345 

prop [AXE] = 0; base [AXE] = NOTHING; /* axe is movable again */ 
report ( "The u bear u eagerly u wolf s u down u your u f ood , u \ 
af ter u which u he u seems u to u calm\n\ 
down u considerably u and u even u becomes u rather u f riendly . " ); 
case DWARF: if (=/tere(F00D)) goto report-default] 
dflag ++ ; 

report ( " You u f ool , u dwarves u eat u only u coal ! uu \ 

Now u you' ve u made u him u REALLY u mad ! " ); 
default : report (default-msg [CALM] ) ; 

} 

report ("There ’ s u nothing u here u it u wants u to u eatu\ 
(except u perhaps u you) . " 


ABSTAIN =0, §13. 

AXE = 34, §11. 
base: object [], §63. 

BEAR = 45, §11. 

BIRD = 10, §11. 

CALM, see §14. 
change-to = macro ( ), §79. 
closed: boolean, §177. 
default-msg: char *[], §15. 
destroy = macro ( ), §65. 
dflag: int, §159. 

DRAGON = 37, §11. 

DRAGON, =38, §11. 

DWARF =20, §11. 

EAT, see §92 and §98. 

FEED = 17, §13. 

FOOD = 22, §11. 
here = macro ( ), §74. 
listen: void (), §72. 
loc: location, §74. 
lost-treasures: int, §89. 
max-obj = 66, §11. 
move = macro ( ), §65. 


note: char *[], §63. 
NOTHING =0, §11. 
obj: object, §77. 
offset: int [], §63. 
place: location [], §63. 
pre-parse: label, §76. 
printf: int (), <stdio.h>. 
prop: int [], §63. 
report = macro ( ), §79. 
report-default: label, §79. 
RUG = 63, §11. 

RUG_ =64, §11. 
scant =96, §18, §53. 
scan2 = 97, §18, §53. 
scan3 = 98, §18, §53. 

SNAKE = 13, §11. 
stay-put = macro, §78. 
streq = macro ( ), §8. 
t: register object, §68. 
TROLL = 41, §11. 
verb: action, §77. 
wordl : char [], §73. 


346 Selected Papers on Fun and Games 

130 . Locking and unlocking involves several interesting special cases. 
(Handle cases of transitive verbs and continue 97 ) += 

case OPEN: case CLOSE: switch ( obj ) { 
case OYSTER: k- 1; 

case CLAM: ( Open/close clam/oyster 134); 
case GRATE: case CHAIN: if (^here( KEYS)) 
report ("YoUuhave u nOukeys ! " ); 

(Open/close grate/chain 131 ); 

case KEYS: report ("You u can’tul°ckuoruunlock u the u keys . " ); 
case CAGE: report ("It u has u no u lock. " ); 
case DOOR: if (prop [DOOR]) default-to (RELAX); 

report ("The u dooruis u extremelyurusty u eaid u refuses u to u open. " ); 
default: goto report-default ; 

} 

131 . ( Open/close grate/chain 131 ) = 

if ( obj = CHAIN) (Open/close chain 132); 
if ( closing ) { 

(Panic at closing time 180 ); continue; 

} 

k = prop [GRATE] ; 

prop [GRATE] = ( verb = OPEN); 

switch (k + 2 * prop [GRATE]) { 

case 0: report ("It u was u already u locked. " ); 

case 1: report ("The u grate u is u now u locked. " ); 

case 2: report ("The u grate u is u now u unlocked. " ); 

case 3: report ("It u was u alr eady u unlocked . " ); 

} 

This code is used in section 130. 

132 . (Open/close chain 132) = 

{ 

if (verb = OPEN) (Open chain 133); 

if (loc / barr) report ("There u is u nothing u here u \ 

to u which u the u chain u can u be u locked. " ); 
if (prop [CHAIN]) report ("It u was u already u locked. " ); 
prop [CHAIN] = 2, base [CHAIN] = CHAIN; 
if (toting (CHAIN)) drop (CHAIN, loc); 
report ("The u chain u is u now u locked. " ); 

} 

This code is used in section 131. 


THE OTHER ACTIONS 


Adventure 347 


133. (Open chain 133) = 

{ 

if {prop [CHAIN] = 0) report ("It u was u already u unlocked. " ); 
if {prop [BEAR] = 0) 

report ("There u is u no u wayutOuget u past u the u bearu\ 

to u unlock u the u chain , u which u is\n\ 
probably u just u as u well . " 

prop [CHAIN] = 0, base [CHAIN] = NOTHING; /* chain is free */ 
if {prop [BEAR] = 3) base [BEAR] = BEAR; 
else prop [BEAR] = 2, base [BEAR] = NOTHING; 
report ("The u chain u is u now u milocked. " ); 

} 

This code is used in section 132. 


barr = 126, §18, §57. 
base: object [], §63. 

BEAR = 45, §11. 

CAGE =5, §11. 

CHAIN = 66, §11. 

CLAM = 17, §11. 

CLOSE =4, §13. 

CLOSE, see §93. 
closing = macro, §177. 
default-to = macro ( ), §79. 
DOOR = 11, §11. 
drop: void (), §64. 

GRATE =3, §11. 
here = macro ( ), §74. 


k: register int, §2. 

KEYS = 1, §11. 
loc: location, §74. 
NOTHING =0, §11. 
obj: object, §77. 

OPEN = 3, §13. 

OPEN, see §93 and §130. 
OYSTER = 18, §11. 
prop: int [], §63. 

RELAX, see §14 and §79. 
report = macro ( ), §79. 
report-default: label, §79. 
toting = macro (), §63. 
verb: action, §77. 


348 Selected Papers on Fun and Games 

134 . The clam/oyster is extremely heavy to carry, although not as 
heavy as the gold. 

#define clam.oyster (obj = CLAM ? "clam" : "oyster") 

(Open/close clam/oyster 134) = 
if (verb = CLOSE) report ("What?"); 
if (-'toting (TRIDENT)) { 

printf ("Youudon’t u have u anything u stronguenough u to u open u the u “/,s" , 

clam.oyster ); 
report (" . "); 

} 

if (toting (obj )) { 

printf ("Iuadviseuyouutouputudowiiutheuy.subef oreuopening u it . uu " , 
clam.oyster)-, 

report (obj = CLAM ? ">STRAIN!<" : ”>WRENCH ! <" ); 

} 

if (obj = CLAM) { 

destroy (CLAM); drop(OYSTER, loc); drop (PEARL, sac); 
report ("A u glistening u pearl u f alls u out u of u the u clamu\ 
and u rolls u away . uu Goodness , \n\ 
this u must u really u be u an u oyster . uu \ 

(I u never u was u very u good u at u identifying\n\ 

bivalves . ) uu Whatever u it u is >u \ 

it u has u now u snapped u shut u again. " ); 

} else report("The u oyster u creaksuOpen,\ 

u revealing u nothing u but u oyster u inside . \n\ 
It u promptly u snaps u shut u again. " ); 

This code is used in section 130. 

135 . You get little satisfaction from asking us to read, unless you hold 
the oyster — after the cave is closed. 

( Handle cases of transitive verbs and continue 97 ) += 
case READ: if (dark) goto cant.see.it ; 
switch (obj) { 
case MAG: 

report ("I ’m u afraid u the u magazineuisuwritten u in u dwarvish. " ); 
case TABLET: report ("\"C0NGRATULATI0NS u \ 

ON u BRINGING u LIGHT u INTO u THE u D ARK-ROOM ! \ " " ) ; 
case MESSAGE: report ("\"This u isunotuthe u maze u where u \ 
the u pirate u hides u his u treasure u chest . \" " ); 
case OYSTER: if (hinted[l\) { 
if (toting (OYSTER)) 

report("Itusays u the u same u thing u it u did u before. " ); 

} 

else if (closed A toting (OYSTER)) { 


THE OTHER ACTIONS 


Adventure 349 


Ojffer(l); continue; 

} 

default: goto report-default ; 

} 

136. OK, that just about does it. We’re left with only one more 
“action verb” to handle, and it is intransitive. In order to penetrate this 
puzzle, you must pronounce the magic incantation in its correct order, 
as it appears on the wall of the Giant Room. A global variable foobar 
records your progress. 

( Handle cases of intransitive verbs and continue 92 } += 
case FEEFIE: while (~>streq(wordl , incantation [k])) fc++; 
if ( foobar = —k) (Proceed foobarically 139); 
if ( foobar = 0) goto nadasucede; 
report ("What ’ s u the u matter , u can’ t u you u read? uu \ 
Nowuyou’dubestustartuover . " ); 

137. (Global variables 7) += 

char *incantation[] = {"f ee" , "f ie" , "foe" , "f oo" , "fum" }; 
int foobar', /* current incantation progress */ 

138. Just after every command you give, we make the foobar counter 
negative if you’re on track, otherwise we zero it. 

( Handle special cases of input 82 ) += 
if ( foobar > 0) foobar = —foobar-, 
else foobar = 0; 


cantsee-it: label, §79. 
CLAM = 17, §11. 

CLOSE, see §93 and §130. 
closed: boolean, §177. 
dark = macro, §84. 
destroy = macro ( ), §65. 
drop: void (), §64. 
FEEFIE = 24, §13. 
hinted: boolean [], §196. 
k: register int, §2. 
loc: location, §74. 

MAG = 19, §11. 

MESSAGE = 46, §11. 
nadasucede: label, §139. 
obj : object , §77. 


offer: void (), §194. 
OYSTER = 18, §11. 

PEARL =62, §11. 
printf: int (), <stdio.h>. 
READ =23, §13. 

READ, see §93. 
report = macro ( ), §79. 
report-default: label, §79. 
sac = 65, §18, §43. 
streq = macro ( ), §8. 
TABLET = 16, §11. 
toting = macro (), §63. 
TRIDENT = 58, §11. 
verb: action, §77. 
wordl: char [], §73. 


350 Selected Papers on Fun and Games 

139. If you get all the way through, we zip the eggs back to the Giant 
Room, unless they’re already there. The troll returns if you’ve stolen 
the eggs back from him. 

( Proceed foobarically 139 ) = 

{ 

foobar = k + 1; 

if ( foobar ^ 4) default.to (RELAX); 
foobar = 0; 

if (place [ EGGS] = giant V (toting (EGGS) A loc = giant)) 
nadasucede : report ( default-msg [WAVE] ) ; 

if (place [EGGS] = limbo A place [TROLL] = limbo A prop [TROLL] = 0) 
prop [TROLL] = 1; 

k = (loc = giant ? 0 : ftere(EGGS) ? 1 : 2); 

move (EGGS , giant ) ; 

report (note[offset [EGGS] + k ]); 

} 

This code is used in section 136. 


MOTIONS 


Adventure 351 


140. Motions. A major cycle comes to an end when a motion verb 
mot has been given and we have computed the appropriate newloc 
accordingly. 

First, we deal with motions that don’t refer directly to the travel table. 
( Handle special motion words 140 } = 

newloc = loc; /* by default we will stay put */ 

if ( mot = NOWHERE) continue; 

if ( mot = BACK) (Try to go back 143); 

if ( mot = LOOK) (Repeat the long description and continue 141 ); 
if (mot = CAVE) { 

if ( loc < minjn-cave ) printf ("Iucan’tusee u where u the u cave u is , u \ 
butuhereaboutSunouStreamucanurunuonXnX 
the u surf ace u f or u long. uu I u would u try u the u stream. \n" ); 
else printf ("Iuneed u more u detailed u instructionsuto u do u that . \n" ); 
continue; 

} 

This code is used in section 75. 


BACK = 15, §9. 

CAVE =34, §9. 
default-msg: char *[], §15. 
default-to = macro ( ), §79. 
EGGS =57, §11. 
foobar: int, §137. 
giant = 76, §18, §47. 
here = macro ( ), §74. 
k : register int, §2. 
limbo = 0, §18. 
loc: location, §74. 

LOOK = 24, §9. 
min-in-cave = 9, §18. 
mot: motion, §77. 


move = macro ( ), §65. 
newloc: location, §74. 
note: char *[], §63. 
NOWHERE = 74, §9. 
offset: int [], §63. 
place: location [], §63. 
printf: int (), <stdio.h>. 
prop: int [], §63. 

RELAX, see §14 and §79. 
report = macro ( ), §79. 
toting = macro ( ), §63. 
TROLL = 41, §11. 

WAVE, see §99. 


352 Selected Papers on Fun and Games 

141. When looking around, we pretend that it wasn’t dark (though 
it may now be dark), so you won’t fall into a pit while staring into the 
gloom. 

(Repeat the long description and continue 141 ) = 

{ 

if (++ look-count < 3) 

print/ (" Sorry .ubutuluamunotuallowedutougiveuinoreudetail . uu \ 

I u will u repeat u the\n\ 
long u description u of u your u location. \n" ); 
was-dark = false ; 
visits [loc] = 0; 

continue; 

} 

This code is used in section 140. 

142. (Global variables 7) += 

int look-count ; /* how many times you’ve asked us to look */ 

143. If you ask us to go back, we look for a motion that goes from 
loc to oldloc , or to oldoldloc if oldloc has forced motion. Otherwise we 
can’t take you back. 

( Try to go back 143 } = 

{ 

l = [forced-move (oldloc) ? oldoldloc : oldloc ); 
oldoldloc = oldloc; 
oldloc = loc; 

if ( l = loc ) (Apologize for inability to backtrack 145 ); 
for ( q = start[loc], qq = A; q < start[loc + 1]; q++ ) { 
ll = q-’dest; 

if (ll = l) goto found; 

if (ll < max-loc A forced-move (ll) A start [ll]-*dest = l) qq = q; 

} 

if (qq = A) { 

printf ( " You u can ’ t u get u there u f rom u here . \n" ) ; continue; 

} 

else q = qq; 
found \ mot = q-mot; 
goto go-for-it; 

} 

This code is used in section 140. 

144. ( Additional local registers 22 ) += 

register location l, ll; 


MOTIONS 


Adventure 353 


145. ( Apologize for inability to backtrack 145 ) = 

printf ( "Sorry ,ubut u I u no u longer u seein u to u remember u \ 
how u you u got u here . \n" ); 
continue; 

} 

This code is used in section 143. 

146. Now we are ready to interpret the instructions in the travel table. 
The following code implements the conventions of section 19. 

{ Determine the next location, newloc 146 ) = 
for (q = start [loc]; q < start[loc + 1]; q++) { 
if (forced-move (loc) V q-mot = mot ) break; 

} 

if (q = start [loc + 1]) (Report on inapplicable motion and continue 148); 
(If the condition of instruction q isn’t satisfied, advance q 147); 
newloc = q-dest\ 

if (newloc < maxJoc) continue; 
if (newloc > maxspec) { 

printf ("’/.sXn", remarks[newloc — maxspec})-, 
stay: newloc = loc\ continue; 

} 

switch ( newloc ) { 

case ppass: (Choose newloc via plover-alcove passage 149 ); 
case pdrop: (Drop the emerald during plover transportation iso); 
goto no-good ; 

case troll: (Cross troll bridge if possible l5l); 

This code is cited in section 19. 

This code is used in section 75. 


dest: location, §19. 
false = 0, §2. 

forced-move = macro (), §59. 
go-for-it: label, §75. 
loc: location, §74. 
location = enum, §18. 
max-loc = 140, §18. 
maxspec = 143, §18. 
mot: motion, §19. 
mot: motion, §77. 
newloc: location, §74. 
no-good: label, §147. 


oldloc: location, §74. 

oldoldloc: location, §74. 

pdrop = 142, §18. 

ppass = 141, §18. 

printf: int (), <stdio.h>. 

q: register instruction *, §22. 

qq: register instruction *, §22. 

remarks: char *[], §20. 

start: instruction *[], §20. 

troll = 143, §18. 

visits: int [], §20. 

was-dark: boolean, §84. 


354 Selected Papers on Fun and Games 

147. (If the condition of instruction q isn’t satisfied, advance q 147) = 
while (1) { 

j = q-cond\ 
if ( j > 300) { 

if ( prop[j % 100] ^ (int)((j - 300)/100)) break; 

} else if ( j < 100) { 

if (j = 0 \/ pct(j)) break; 

} else if ( toting(j % 100) V ( j > 200 A is-at-loc(j % 100))) break; 
no -good , : 

for (qq = q++ ; 

q^dest = qq-dest A q-’cond = qq-cond', 

?++) ; 

} 

This code is used in section 146. 

148. Here we look at verb just in case you asked us to ‘find gully' 
or something like that. 

(Report on inapplicable motion and continue 148) = 

{ 

if (mot = CRAWL) printf (" Which u way?" ); 

else if ( mot = XYZZY V mot = PLUGH) printf (default-msg[WAVE]); 
else if (verb = FIND V verb = INVENTORY) printf (default-ms g[ FIND]); 
else if (mot < FORWARD) 
switch (mot) { 

case IN: case OUT: printf ("I u don’ t u know u in u from u out u here . uu \ 
Use u compass u points u or u name u something\n\ 
inuthe u generaludirection u you u wantuto u go. " ); break; 

case FORWARD: case L: case R: 

printf ( " I u am u unsur e u how u you u are u f ac ing . uu \ 

Use u compass u pointSuOr u nearbyuObjects . " ); break; 
default: printf ("There u is u no u wayutOugo u inuthatudirection. " ); 

} else prmt/("Iudon’t u know LJ how u to u applyu'thatuWord u here . " ); 
printf ("\ n"); continue; /* newloc = loc */ 

} 

This code is used in section 146. 


MOTIONS 


Adventure 355 


149. Only the emerald can be toted through the plover-alcove passage 
— not even the lamp. 

( Choose newloc via plover-alcove passage 149 ) = 

if ( holding 50V ( toting ( EMERALD ) A holding = 1)) { 
newloc = alcove + proom — loc; continue; 

/* move through the passage */ 

} else { 

printf ( " Something u you ’ re u carry ing u \ 

won ’ t u f it u through u the u tunnel u with u you . \n\ 

You ’dijbestutakeuinventoryuandudropusomething . \n" ); 
goto stay; 

} 

This code is used in section 146. 

150. The pdrop command applies only when you’re carrying the emer- 
ald. We make you drop it, thereby forcing you to use the plover-alcove 
passage if you want to get it out. We don’t actually tell you that it was 
dropped; we just pretend you weren’t carrying it after all. 

( Drop the emerald during plover transportation 150 } = 
drop ( EMERALD ,loc); 

This code is used in section 146. 


alcove = 89, §18, §51. 
cond: int, §19. 

CRAWL = 21, §9. 
default-msg: char *[], §15. 
dest: location, §19. 
drop: void (), §64. 

EMERALD =60, §11. 

FIND, see §100. 

FORWARD = 14, §9. 
holding: int, §63. 

IN = 12, §9. 

INVENTORY, see §94 and §100. 
is-atJoc: void (), §66. 
j: register int, §2. 

L = 10, §9. 

loc: location, §74. 

mot: motion, §77. 


newloc: location, §74. 

OUT = 13, §9. 

pet = macro ( ), §157. 

pdrop = 142, §18, §146. 

PLUGH = 71, §9. 

printf: int (), <stdio.h>. 

proom = 90, §18, §51. 

prop: int [j, §63. 

q: register instruction *, §22. 

qq: register instruction *, §22. 

R=ll, §9. 

stay: label, §146. 

toting = macro (), §63. 

verb: action, §77. 

WAVE, see §99. 

XYZZY = 70, §9. 


356 Selected Papers on Fun and Games 

151. Troll bridge crossing is treated as a special motion so that 
dwarves won’t wander across and encounter the bear. 

You can get here only if TROLL is in limbo but TR0LL2 has taken 
its place. Moreover, if you’re on the southwest side, prop [TROLL] will 
be nonzero. If prop [TROLL] is 1, you’ve crossed since paying, or you’ve 
stolen away the payment. Special stuff involves the bear. 

( Cross troll bridge if possible 151 ) = 

if (prop [TROLL] = 1) (Block the troll bridge and stay put 152); 
newloc = neside + swside — loc ; /* cross it */ 

if (prop [TROLL] = 0) prop [TROLL] = 1; 
if (-^toting (BEAR)) continue; 

printf (" Just u as u you u reach u the u otheruside )U \ 
the u bridge u bucklesubeneath u the\n\ 
weight u of uthe u bear , u \ 

who u was u still u following u you u around.uuYou\n\ 

scrabble u desperately u f or u support , u \ 

but u as u the,jbridgeuCollapses u you\n\ 
stumble u back u and u f all u into u the u chasm. \n" ); 
prop [BRIDGE] = 1; prop [TROLL] = 2; 

drop (BEAR, newloc)-, base [BEAR] = BEAR; prop [BEAR] = 3; 

/* the bear is dead */ 

if (prop [SPICES] < 0 A place [SPICES] > neside) lost-treasures ++; 
if (prop [CHAIN] < 0 A place [CHAIN] > neside) lost-treasures ++; 
oldoldloc = newloc-, /* if you are revived, you got across */ 
goto death ; 

This code is used in section 146. 

152. (Block the troll bridge and stay put 152) = 

{ 

move (TROLL, swside)-, move (TR0LL_ , neside); prop [TROLL] = 0; 

destroy (TR0LL2 ); destroy (TR0LL2. ) ; 

move (BRIDGE , swside ) ; move (BRIDGE. , neside ) ; 

printf ("'/,s\n" , note [offset [TROLL] + 1]); 

goto stay, 

} 

This code is used in section 151. 


MOTIONS 


Adventure 357 

153 . Obstacles might still arise after the choice of newloc has been 
made. The following program is executed at the beginning of each major 
cycle. 

( Check for interference with the proposed move to newloc 153 ) = 
if ( closing A newloc < min.in.cave A newloc limbo) { 

(Panic at closing time 180 ); newloc = loc\ 

} else if ( newloc / loc) 

( Stay in loc if a dwarf is blocking the way to newloc 176 }; 

This code is used in section 75. 


base: object [], §63. 
BEAR = 45, §11. 

BRIDGE = 39, §11. 
BRIDGE. =40, §11. 
CHAIN = 66, §11. 
closing = macro, §177. 
death : label, §189. 
destroy = macro ( ), §65. 
drop : void ( ), §64. 
limbo = 0, §18. 
loc: location, §74. 
lost-treasures: int, §89. 
min-in-cave = 9 , §18. 
move = macro ( ), §65. 
neside = 118, §18, §57. 


newloc: location, §74. 
note: char *[], §63. 
offset: int [], §63. 
oldoldloc: location, §74. 
place: location [], §63. 
printf: int (), <stdio.h>. 
prop: int [], §63. 

SPICES =65, §11. 
stay: label, §146. 
swside = 105, §18, §55. 
toting = macro ( ), §63. 
TROLL = 41, §11. 

TROLL. =42, §11. 

TR0LL2 =43, §11. 

TR0LL2. =44, §11. 


358 Selected Papers on Fun and Games 

154. Random numbers. You won’t realize it until you have played 
the game for awhile, but adventures in Colossal Cave are not determin- 
istic. Lots of things can happen differently when you give the same 
input, because caves are continually changing, and the dwarves don’t 
have consistent aim, etc. 

A simple linear congruential method is used to provide numbers that 
are random enough for our purposes. 

( Subroutines 6 ) += 
int ran ARGS((int)); 
int ran (range) 

int range-, /* for uniform integers between 0 and range — 1 */ 

rx = (1021 * rx ) & ; /* multiply by 1021, modulo 2 20 */ 

return ( range * rx) 3> 20; 

} 

155. (Global variables 7} += 

int rx ; /* the last random value generated * / 

156. Each run is different. 

( Initialize the random number generator 156 ) = 
rx = (((int) time (A)) & # fffff) | 1; 

This code is used in section 200. 

157. The pet macro returns true a given percentage of the time. 
#define pct(r) (ran (100) < r) 

( Give optional plugh hint 157 ) = 
if ( loc = y2 A pet (25) A -i closing ) 

printf ("A u hollow u voice u says u \"PLUGH\" . \n" ); 

This code is used in section 86. 

158. We kick the random number generator often, just to add variety 
to the chase. 

( Make special adjustments before looking at new input 85 ) += 
k = ran(0); 


DWARF STUFF 


Adventure 359 

159. Dwarf stuff. We’ve said a lot of vague stuff about dwarves; 
now is the time to be explicit. Five dwarves roam about the cave. Ini- 
tially they are dormant but eventually they each walk about at random. 
A global variable called dflag governs their level of activity: 

0 no dwarf stuff yet (we wait until you reach the Hall of Mists) 

1 you’ve reached that hall, but haven’t met the first dwarf 

2 you’ve met one; the others start moving, but no knives thrown yet 

3 a knife has been thrown, but it misses 

4 knives will hit you with probability .095 

5 knives will hit you with probability .190 

6 knives will hit you with probability .285 

and so on. Dwarves get madder and madder as dflag increases; this 
increases their accuracy. 

A pirate stalks the cave too. He acts a lot like a dwarf with respect to 
random walks, so we call him dwarf [0], but actually he is quite different. 
He starts at the location of his treasure chest; you won’t see that chest 
until after you’ve spotted him. 

The present location of dwarf [i] is dloc[i\ ; initially no two dwarves 
are adjacent. The value of dseen[i\ records whether or not dwarf i is 
following you. 

#define nd 5 /* this many dwarves */ 

#define chestJoc dead2 
#define messageJoc pony 
{ Global variables 7 ) += 

int dflag-, /* how angry are the dwarves? */ 

int dkill ; /* how many of them have you killed? */ 

location dloc[nd + 1] = {chestJoc, hmk, wfiss , y2 , Uke3 , complex}- 
/ * dwarf locations * / 

location odloc[nd + 1]; /* prior locations */ 

boolean dseen[nd + 1]; /* have you been spotted? */ 


ARGS = macro (), §3. 
boolean =enum, §2. 
closing = macro, §177. 
complex = 61, §18, §42. 
deadS = 108, §18, §56. 
dwarf: void ( ), §160. 
hmk = 50, §18, §40. 
k: register int, §2. 


likeS = 22, §18, §36. 
loc: location, §74. 
location =enum, §18. 
pony =48, §18, §39. 
printf : int (), <stdio.h>. 
time: time.t (), <time.h>. 
wfiss = 18, §18, §34. 

1/2 = 54, §18, §41. 


360 Selected Papers on Fun and Games 

160. The following subroutine is often useful. 

( Subroutines 6 } += 

boolean dwarf ARGS((void)); 

boolean dwarf () /* is a dwarf present? */ 

{ 

register int j; 

if ( dflag < 2) return false', 
for ( j = 1; j < nd; j++) 

if ( dloc[j ] = loc) return true', 
return false; 

} 

161. Just after you’ve moved to a new loc, we move the other guys. 
But we bypass all dwarf motion if you are in a place forbidden to the 
pirate, or if your next motion is forced. In particular, this means that 
the pirate can’t steal the return toll, and dwarves can’t meet the bear. 
It also means that dwarves won’t follow you into a dead end of the maze, 
but c’est la vie; they’ll wait for you outside the dead end. 

( Possibly move dwarves and the pirate 161 ) = 
if ( loc < max-pirateJoc A loc ^ limbo) { 
if (dflag = 0) { 

if ( loc > minJowerJoc) dflag = 1; 

} 

else if (dflag = 1) { 

if (loc > minJowerJoc Apct(5)) (Advance dflag to 2 162 ); 

} 

else ( Move dwarves and the pirate 164 ) ; 

} 

This code is used in section 75. 

162. When level 2 is reached, we silently kill 0, 1, or 2 of the dwarves. 
Then if any of the survivors is in the current location, we move him to 
nugget; thus no dwarf is presently tracking you. Another dwarf does, 
however, toss an axe and grumpily leave the scene. 

(The grumpy dwarf might throw the axe while you’re in the maze of 
all-different twists, even though other dwarves never go in there!) 
(Advance dflag to 2 162 ) = 

{ 

dflag = 2; 

for (j = 0; j < 2; j++) 

if (pct(50)) dloc[ 1 + ran(nd)] = limbo; 
for (j = 1; j < nd; j++) { 

if (dloc[j] = loc ) dloc[j] = nugget; 


DWARF STUFF 


Adventure 361 


odloc[j] = dloc[j]; 

} 

printf ("A u llttle u dwarf ujust u walked u around u a u corner >u \ 
saw u you, u threw u a u little\n\ 

axe u at u you , u cur sed , u and u ran u away . uu (The u axe u missed . ) \n" ) : 
drop (AXE, loc); 

} 

This code is used in section 161. 

163. It turns out that the only way you can get rid of a dwarf is to 
attack him with the axe. You’ll hit him 2/3 of the time; in either case, 
the axe will be available for reuse. 

( Throw the axe at a dwarf 163 ) = 

for ( j = 1; j < nd; j++) 
if ( dloc[j ] = loc) break; 
if (ran (3) < 2) { 

dloc[j] = limbo; dseen[j] = 0; dkill-H-; 

if (dkill = 1) printf ("You u killed u a u little u dwarf . u \ 

uThe u body u vanishes u in u a u cloud u of u greasy\n\ 

black u smoke . \n" ); 

else printf ("You u killed u a u little u dwarf . \n" ); 

} else printf ("You u attack u a u little u dwarf , u \ 

but u he u dodges u out u of u the u way . \n" ) ; 
drop (AXE, loc); stay.put; 

} 

This code is used in section 122. 


ARGS = macro ( ), §3. 

AXE = 34, §11. 
boolean = enum, §2. 
dflag: int, §159. 
dkill: int, §159. 
dloc : location [], §159. 
drop: void (), §64. 
dseen: boolean [], §159. 
false = 0, §2. 
j: register int, §2. 
limbo = 0, §18. 


loc: location, §74. 
max-pirateJoc = 108, §56. 
minJowerJoc = 15, §18. 
m2 = 5, §159. 
nugget = 16, §18, §33. 
odloc: location [], §159. 
pet = macro ( ), §157. 
printf: int (), <stdio.h>. 
ran: void ( ), §154. 
stay^put = macro, §78. 
true = 1, §2. 


362 Selected Papers on Fun and Games 

164. Now things are in full swing. Dead dwarves don’t do much 
of anything, but each live dwarf tends to stay with you if he’s seen 
you. Otherwise he moves at random, never backing up unless there’s no 
alternative. 

( Move dwarves and the pirate 164 ) = 

{ 

dtotal = attack = stick — 0; 

/ * initialize totals for possible battles * / 
for (j = 0; j < nd; j++) 
if ( dloc[j ] / limbo) { 

register int i; 

{ Make a table of all potential exits, ploc[ 0] through ploc[i — 1] 166 ); 
if (i = 0) i = l,ploc[0] = odloc[j ]; 
odloc[j ] = dloc[j ]; 

dloc[j] = ploc[ran(i)]- /* this is the random walk */ 
dseen[j] = ( dloc[j] = loc V odloc[j] = loc V ( dseen[j] A loc > 
minJowerJoc )); 

if (dseen[j]) ( Make dwarf j follow 167); 

_ } 

if ( dtotal ) { Make the threatening dwarves attack l7o); 

} 

This code is used in section 161. 

165. {Global variables 7) += 

int dtotal ; /* this many dwarves are in the room with you */ 

int attack ; /* this many have had time to draw their knives */ 

int stick ; /* this many have hurled their knives accurately */ 

location ploc [19]; /* potential locations for the next random step */ 

166. Random-moving dwarves think scanl , scan2 , and scan3 are 
three different locations, although you will never have that perception. 
(Make a table of all potential exits, ploc[ 0] through ploc[i — 1] 166 ) = 

for (i = 0 , q = start[dloc[j ]\ ; q < start [dloc[j] + 1]; </++) { 
newloc = q-dest\ 

if ( newloc > minJowerJoc A newloc ^ odloc[j ] A newloc ^ dloc[j] A 
(i = 0 V newloc / ploc[i — 1]) A i < 19 A q-cond / 100 A 
newloc < (j = 0 ? max-pirateJoc : mimforcedJoc — 1)) 
ploc[i++] = newloc ; 

} 

This code is used in section 164. 


DWARF STUFF 


Adventure 363 

167. A global variable knifeJoc is used to remember where dwarves 
have most recently thrown knives at you. But as soon as you try to refer 
to the knife, we tell you it’s pointless to do so; knifeJoc is -1 thereafter. 
( Make dwarf j follow 167 ) = 

{ 

dloc[j] = loc, 

O' = 0 ) ( Make the pirate track you 172 ) 
else { 
dtotal++-, 

if (odloc[j] = dloc[j]) { 
attack -H-; 

if ( knifeJoc > 0) knifeJoc = loc ; 
if {ran (1000) < 95 * ( dflag - 2)) stick ++-, 

} 

} 

This code is used in section 164 . 

168. (Global variables 7) += 

mt knifeJoc ; /* place where knife was mentioned, or -1 */ 

169. ( Make special adjustments before looking at new input 85 ) += 
if (knifeJoc > limbo A knifeJoc / loc) knifeJoc = limbo ; 


cond: int, §19. 
dest: location, §19. 
dflag: int, §159. 
dloc : location [], §159. 
dseen : boolean [], §159. 
j: register int, §2. 
limbo = 0, §18. 
loc : location, §74. 
location =enum, §18. 
max-piratedoc = 108, §56. 
minjorcedJoc = 129, §18. 


minJowerJoc = 15, §18. 

nd = 5, §159. 

newloc : location, §74. 

odloc: location [j, §159. 

q: register instruction *, §22. 

ran: void ( ), §154. 

scant =96, §18, §53. 

scanS =97, §18, §53. 

scanS = 98, §18, §53. 

start: instruction *[], §20. 


364 Selected Papers on Fun and Games 

170. We actually know the results of the attack already; this is where 
we inform you of the outcome, pretending that the battle is now taking 
place. 

( Make the threatening dwarves attack 170 ) = 

{ _ 

if (dtotal = 1) prmt/("There u is u a u threatening u little u dwarf " ); 
else printf ("Thereuareu’/.duthreateningulittleudwarves" , dtotal ); 
printf (" u in u the u room u with u you ! \n" ); 
if ( attack ) { 

if ( dflag = 2) dflag = 3; 

if ( attack = 1) k = 0, printf (" One u sharp u nasty u knif e u is u thrown" ); 
else k = 2, printf ("u‘/.d u of u them u throw u knives" , attack); 
printf (" u at u you u — u"); 

if ( stick < 1) printf ("7,s !\n" , attack.msg[k + stick]); 
else printf ("7.d u of u them u get u you! \n" , stick); 
if (stick) { 

oldoldloc = loc; goto death; 

} 

} 

} 

This code is used in section 164. 

171. (Global variables 7) += 

char *attack-msg[] = {"it u misses" , "it u gets u you" , 

"none u of u them u hit u you" , "one u of u them u gets u you" }; 

172. The pirate leaves you alone once you have found the chest. Oth- 
erwise he steals all of the treasures you’re carrying, although he ignores 
a treasure that’s too easy. (The pyramid is too easy, if you’re in the 
Plover Room or the Dark-Room.) 

You spot the pirate if he robs you, or when you have seen all of the 
possible treasures (except, of course, the chest) and the current location 
has no treasures. Before you’ve spotted him, we may give you a vague 
indication of his movements. 

We use the value of place [MESSAGE] to determine whether the pirate 
has been seen; the condition of place [CHEST] is not a reliable indicator, 
since the chest might be in limbo if you’ve thrown it to the troll. 

#define pirate.not.spotted (place [MESSAGE] = limbo) 

^define too.easy (i) ( i = PYRAMID A (loc = proom V loc = droorn)) 

( Make the pirate track you 172 ) = 

{ _ 

if (loc / max-pirateJoc A prop [CHEST] < 0) { 

for (i = min.treasure , k = 0; i < max-obj; i++) { 


DWARF STUFF 


Adventure 365 


if (~<too-easy (?) & toting (i)) { 
k = — 1; break; 

} 

if ( here(i )) k = 1; 

} 

if ( k < 0) (Take booty and hide it in the chest 173) 
else if ( tally ~ lost-treasures + 1 A k = 0 A 

pirate-not-spotted A prop[LAMP] A here(LAMP)) 
( Let the pirate be spotted 175 ) 
else if [odloc [0] ^ dloc[ 0] A pet (20)) 

printf ("There u are u f aint u rustling u noises u \ 
from u the u darkness u behind u you. \n" ); 

} 

This code is used in section 167. 


attack: int, §165. 
CHEST = 56, §11. 
death: label, §189. 
dflag: int, §159. 
dloc: location [], §159. 
droom = 91, §18, §51. 
dtotal: int, §165. 
here = macro ( ), §74. 
i: register int, §164. 
k: register int, §2. 
LAMP =2, §11. 
limbo =0, §18. 
loc: location, §74. 
lost-treasures: int, §89. 
max-obj =66, §11. 


max-pirateJoc = 108, §56. 
MESSAGE =46, §11. 
min-treasure = 51, §11. 
odloc: location [], §159. 
oldoldloc: location, §74. 
pet = macro (), §157. 
place: location [], §63. 
printf: int (), <stdio.h>. 
proom = 90, §18, §51. 
prop: int [], §63. 

PYRAMID = 61, §11. 
stick: int, §165. 
tally: int, §89. 
toting = macro ( ), §63. 


366 Selected Papers on Fun and Games 

173. The pirate isn’t secretive about the fact that his chest is some- 
where in a maze. However, he doesn’t say which maze he means. Nor 
does he explain why he is interested in treasures only when you are 
carrying them; evidently he just likes to see you squirm. 

(Take booty and hide it in the chest 173 ) = 

{ 

print f ("Dut u from u the u shadows u behindijyou u \ 

pounces u a u bearded u pirate!uu\"Har, u har,\"\n\ 

he u chortles , u \ " I ’ ll u just u take u all u this u booty u \ 
and u hide u it u away u with u me\n\ 
chest u deep u in u the u maze ! \" U u\ 

He u snatches u your u treasure u and u vanishes u into\n\ 

the u gloom. \n" ); 

(Snatch all treasures that are snatchable here 174 ); 
if ( pirate-notspotted ) { 

move-chest : move (CHEST, chest Joe)-, move (MESSAGE, message Joe); 

dloc[ 0] = odloc[ 0] = chest Joe- 
dseen[0] = false-, 

} 

This code is used in section 172. 

174. (Snatch all treasures that are snatchable here 174 ) = 
for (i = min-treasure; i < max-obj; *++) 

if (-itoo-easy (i)) { 

if (base[i] = NOTHING A place[i] = loc) carry (i); 
if (toting(i)) drop (i, chest Joe); 

} 

This code is used in section 173. 

175. The window rooms are slightly lighted, but you don’t spot the 
pirate there unless your lamp is on. (And you do spot him even if the 
lighted lamp is on the ground.) 

( Let the pirate be spotted 175 ) = 

{ 

printf ("There u are u f aint u rustling u noises\ 

u from u the u darkness u behind u you . uuA s uy°u\n\ 
turn u t owar d u them , u \ 

theubeamuofuyourulampuf alls u across u a u bearded u pirate . \n\ 
He u is u carry ing u a u large u chest . uu \ 

\"Shiver u me u timbers ! \" u he u cries , U \"I ’ ve\n\ 
been u spotted ! U ul 1 dubestuhieuineself u of f utOutheumazeuX 
to u hide u me u chest ! \"\n\ 

With u that , u he u vanishes u into u the u gloom. \n" ); 


DWARF STUFF 


Adventure 367 


goto move-chest ; 

} 

This code is used in section 172. 

176. One more loose end related to dwarfs needs to be addressed here 
If you’re coining from a place forbidden to the pirate, so that the dwarves 
are rooted in place, we let you get out (and be attacked). Otherwise, 
if a dwarf has seen you and has come from where you want to go, he 
blocks you. 

We use the fact that loc < max-pirateJoc implies -^forced-move (loc). 

{ Stay in loc if a dwarf is blocking the way to newloc 176 ) = 
if ( loc < max-pirateJoc) { 
for ( j = 1; j < nd-, j-H-) 

if ( odloc[j ] = newloc A dseen[j ]) { 

printf ( A u little u dwarf u with u a u big u knif e u \ 
blocks u your u way . \n" ); 
newloc = loc ; break; 

} 

} 

This code is used in section 153. 


base : object [], §63. 
carry: void ( ), §65. 

CHEST = 56, §11. 
chest doc = macro, §159. 
dloc: location [], §159. 
drop: void ( ), §64. 
dseen: boolean [], §159. 
false = 0, §2. 

forced-move = macro ( ), §59. 
i: register int, §164. 
j: register int, §2. 
loc: location, §74. 
max-obj =66, §11. 
max-pirate-loc = 108, §56. 


MESSAGE =46, §11. 
message-loc = macro, §159. 
min-treasure = 51, §11. 
move = macro (), §65. 
nd = 5, §159. 
newloc: location, §74. 

NOTHING =0, §11. 
odloc : location [], §159. 
pirate-not-spotted = macro, §172. 
place: location [], §63. 
printf: int (), <stdio.h>. 
too-easy = macro ( ), §172. 
toting = macro ( ), §63. 


368 Selected Papers on Fun and Games 

177. Closing the cave. You get to wander around until you’ve 
located all fifteen treasures, although you need not have taken them yet. 
After that, you enter a new level of complexity: A global variable called 
clockl starts ticking downwards, every time you take a turn inside the 
cave. When it hits zero, we start closing the cave; then we sit back and 
wait for you to try to get out, letting clock2 do the ticking. The initial 
value of clockl is large enough for you to get outside. 

#define closing ( clockl < 0) 

( Global variables 7 ) += 

int clockl = 15, clock2 = 30; /* clocks that govern closing time */ 

boolean panic, closed; /* various stages of closedness */ 

178. Location Y2 is virtually outside the cave, so clockl doesn’t tick 
there. If you stay outside the cave with all your treasures, and with the 
lamp switched off, the game might go on forever; but you wouldn’t be 
having any fun. 

There’s an interesting hack by which you can keep tally positive until 
you’ve taken all the treasures out of the cave. Namely, if your first moves 
are 


in, take lamp, plugh, on, drop lamp, s, take silver, 
back, take lamp, plugh, out, drop silver, in, 

the silver bars will be at road; but prop [SILVER] will still be -1 and 
tally will still be 15. You can bring the other 14 treasures to the house 
at your leisure; then the tally will drop to zero when you step outside 
and actually see the silver for the first time. 

(Check the clocks and the lamp 178) = 

if ( tally = 0 A loc > minJowerJoc A loc ^ y2) clockl — ; 
if ( clockl = 0) (Warn that the cave is closing 179) 
else { 

if ( clockl < 0) clock2 — ; 

if ( clock2 = 0) (Close the cave 181 ) 

else (Check the lamp 184); 

} 

This code is used in section 76. 

179. At the time of first warning, we lock the grate, destroy the crystal 
bridge, kill all the dwarves (and the pirate), remove the troll and the 
bear (unless dead), and set closing to true. It’s too much trouble to 
move the dragon, so we leave it. From now on until clock2 runs out, 
you cannot unlock the grate, move to any location outside the cave, or 
create the bridge. Nor can you be resurrected if you die. 


CLOSING THE CAVE 


Adventure 369 


(Warn that the cave is closing 179) = 

Vrintf ( " A u sepulchral u vo ice , u \ 

reverberating u through u the u cave , u says , u \"Cave\n\ 
closing u soon. uu All u adventurers u exit u iimnediately u \ 

through u main u off ice ,\"\n" ); 

clock 1 = — 1; 

prop [GRATE] = 0; prop [CRYSTAL] = 0; 

for ( j = 0; j < nd; j++) dseen[j] = 0, dloc[j] = limbo-, 

destroy (TROLL ); destroy (TROLL. ) ; 

move ( TR0LL2 , swside ) ; move (TR0LL2. , neside ) ; 

move (BRIDGE, swside ); more (BRIDGE., neside); 

if (prop [BEAR] ^ 3) destroy (BEAR); 

prop [CHAIN] = 0; base [CHAIN] = NOTHING; 

prop [AXE] = 0; 6ase[AXE] = NOTHING; 

This code is used in section 178. 

180. If you try to get out while the cave is closing, we assume that you 
panic; we give you a few additional turns to get frantic before we close. 
(Panic at closing time iso) = 

if {^panic) clock2 = 15, panic = true-, 

printf ("Aumysterious u recorded u voice u \ 

groans u into u lif e u and u announces : \n\ 
\"This u exit u is u closed. uu \ 

p lease u leave u via u main u of f ice . \"\n" ); 

This code is used in sections 131 and 153. 


AXE = 34, §11. 
base: object [], §63. 
BEAR = 45, §11. 
boolean = enum, §2. 
BRIDGE =39, §11. 
BRIDGE. =40, §11. 
CHAIN = 66, §11. 
CRYSTAL = 14, §11. 
destroy = macro (), §65. 
dloc: location [], §159. 
dseen: boolean [], §159. 
GRATE =3, §11. 
house =3, §18, §25. 
j: register int, §2. 
limbo = 0, §18. 
loc : location, §74. 
minjowerjoc = 15, §18. 


move = macro ( ), §65. 

nd = 5, §159. 

neside = 118, §18, §57. 

NOTHING =0, §11. 

printf: int (), <stdio.h>. 

prop: int [], §63. 

road = 1, §18, §23. 

SILVER = 53, §11. 
swside = 105, §18, §55. 
tally: int, §89. 

TROLL =41, §11. 

TROLL. =42, §11. 

TR0LL2 =43, §11. 

TR0LL2. =44, §11. 
true = 1, §2. 

2/2=54, §18, §41. 


370 Selected Papers on Fun and Games 

181. Finally, after clock2 hits zero, we transport you to the final 
puzzle, which takes place in the previously inaccessible storage room. We 
have to set everything up anew, in order to use the existing machinery 
instead of writing a special program. We are careful not to include keys 
in the room, since we don’t want to allow you to unlock the grate that 
separates you from your treasures. There is no water; otherwise we 
would need special code for watering the beanstalks. 

The storage room has two locations, neend and swend . At the north- 
east end, we place empty bottles, a nursery of plants, a bed of oysters, a 
pile of lamps, rods with stars, sleeping dwarves, and you. At the south- 
west end we place a grate, a snake pit, a covey of caged birds, more rods, 
and pillows. A mirror stretches across one wall. But we destroy all ob- 
jects you might be carrying, lest you have some that could cause trouble, 
such as the keys. We describe the flash of light and trundle back. 

From the fact that you’ve seen all the treasures, we can infer that the 
snake is already gone, since the jewels are accessible only from the Hall of 
the Mountain King. We also know that you’ve been in the Giant Room 
(to get eggs); you’ve discovered that the clam is an oyster (because of the 
pearl); the dwarves have been activated, since you’ve found the chest. 
Therefore the long descriptions of neend and swend will make sense to 
you when you see them. 

Dear reader, all the clues to this final puzzle are presented in the 
program itself, so you should have no trouble finding the solution. 

( Close the cave 181 ) = 

{ 

printf ("The u sepulchral u voice u intones , u \ 

\"The u cave u is u now u closed.\" uu As u the u echoes\n\ 
fade, u there u is u a u blinding u f lash u of u light u \ 

(and u a u small u puf f u of u orange\n\ 
smoke) . u -u -u .uuuuThen u your u eyes u ref ocus ; u \ 
you u look u around u and u f ind. . An"); 
move (BOTTLE , neend ) ; prop [BOTTLE] = -2; 
move (PL ANT, neend); prop [PLANT] = — 1; 
more(0YSTER, neend)-, prop [OYSTER] = —1; 
move (LAMP, neend); prop [LAMP] = — 1; 
move (ROD, neend)-, prop [ROD] = — 1; 
move (DWARF, neend)-, prop[DWARF] = —1; 
move (MIRROR, neend)', prop[MIRR0R] = —1; 
loc = oldloc = neend ; 

move (GRATE , swend ) ; /* prop [GRATE] still zero */ 

move (SHAKE, swend); prop[SNAKE] = —2; 
move (BIRD, swend); prop [BIRD] = —2; 


CLOSING THE CAVE 


Adventure 371 


move (CAGE, swend); prop [CAGE] = -1; 
move (R0D2, s wend); prop [R0D2] = -1; 
more(PILLOW, swend)- prop [PILLOW] = -1; 
move (MIRR0R_ , swend ) ; 
for (j = 1; j < max-obj; j++) 
if (toting(j)) destroy (j); 
closed = true; 
bonus = 10; 
stay-put ; 

} 

This code is used in section 178. 

182. Once the cave has closed, we look for objects being toted with 
prop < 0; their property value is changed to -1-prop. This means they 
won t be described until they’ve been picked up and put down, separate 
from their respective piles. 

( Make special adjustments before looking at new input 85 ) += 
if ( closed ) { 

if (prop [OYSTER] < 0 A toting (OYSTER)) 
printf ("°/,s\n" , note [ojifset [OYSTER] + 1]); 
for (j = 1; j < max-obj-, j++) 

if (toting (j) A prop[j] < 0) prop[j] = — 1 — prop[j]; 


BIRD = 10, §11. 
bonus: int, §193. 
BOTTLE = 23, §11. 

CAGE = 5, §11. 
clocks-, int, §177. 
closed : boolean, §177. 
destroy = macro ( ), §65. 
DWARF =20, §11. 

GRATE = 3, §11. 
j: register int, §2. 
LAMP =2, §11. 
loc: location, §74. 
max-obj =66, §11. 
MIRROR = 26, §11. 
MIRR0R_ =27, §11. 
move = macro ( ), §65. 


neend = 127, §18, §58. 
note: char *[], §63. 
offset: int [], §63. 
oldloc: location, §74. 
OYSTER = 18, §11. 

PILLOW = 12, §11. 

PLANT =28, §11. 

printf: int (), <stdio.h>. 

prop: int [], §63. 

ROD = 6, §11. 

R0D2 = 7, §11. 

SNAKE = 13, §11. 
stay.put = macro, §78. 
swend = 128, §18, §58. 
toting = macro ( ), §63. 
true = 1, §2. 


372 Selected Papers on Fun and Games 

183. Death and resurrection. Only the most persistent adven- 
turers get to see the closing of the cave, because their lamp gives out 
first. For example, if you have lost the ability to find any treasures, tally 
will never go to zero. 

( Zap the lamp if the remaining treasures are too elusive 183 ) = 
if ( tally = lost-treasures A tally > 0 A limit > 35) limit = 35; 

This code is used in section 88. 

184. On every turn, we check to see if you are in trouble lampwise. 

( Check the lamp 184 ) = 

{ 

if (prop [LAMP] = 1) limit — ; 

if ( limit < 30 A here (BATTERIES) A prop [BATTERIES] = 0 A fcere(LAMP)) 

( Replace the batteries 186 ) 
else if (limit = 0) (Extinguish the lamp 187 ) 
else if (limit < 0 A loc < min-in-cave ) { 
printf ("There ’ s u not u much u point u in u \ 

wander ing u around u out u here , u and u you u can ’ t \n\ 
explore u the u cave u without u a u lamp . uu \ 

So u let ’ SujustLjCalluituauday . \n" ); 
goto givejup ; 

} else if (limit < 30 A -> warned A ftere(LAMP)) { 
printf ("Your u lamp u is u gettingudim" ); 
if (prop [BATTERIES] = 1) 

printf ( " , u and u you ’ re u out u of u spare u batteries . uu You ’ d\n\ 
best u start u wrapping u this u up . \n" ); 
else if (place [BATTERIES] = limbo) 

printf (" .uuYou’d u best u start u wrapping u this u up, u unless\n\ 
you u can u f ind u some u fresh u batteries . uu \ 
I u seem u to u recall u that u there ’ s\n\ 
a u vending u machine u in u the u maze . ULJ \ 
Bring u some u coins u with u you . \n" ); 
else printf (" . □uYou 1 d u best u go u back u f or u those u batteries . \n" ); 
warned - true; 

} 

} 

This code is used in section 178. 

185. (Global variables 7) += 
boolean warned; 

/ * have you been warned about the low power supply? * / 

186. The batteries hold a pretty hefty charge. 

( Replace the batteries 186 ) = 


DEATH AND RESURRECTION 


Adventure 373 


{ 

printf ("Y our u lamp u i s u get t ing u dim . uu \ 

I ’m u taking u the u liberty u of u replacing\n\ 
the u batteries . \n" ); 
prop [BATTERIES] = 1; 

if ( toting (BATTERIES ) ) drop (BATTERIES, loc); 
limit = 2500; 

} 

This code is used in section 184. 

187. (Extinguish the lamp 187 } = 

{ 

limit = -1; prop [LAMP] = 0; 

if (here(LAMP)) printf (" Your u lamp u has u run u out u of u power . " 

This code is used in section 184. 

188. The easiest way to get killed is to fall into a pit in pitch darkness. 

( Deal with death and resurrection 188 ) = 

pitch-dark : 

printf ( " You u f ell u into u aupit u and u broke u every u bone u in u your u body ! \n" ); 
oldoldloc = loc, 

See also sections 189, 191, and 192. 

This code is used in section 2. 


BATTERIES = 49, §11. 
boolean = enum, §2. 
drop: void (), §64. 
give-up : label, §95. 
here = macro ( ), §74. 
LAMP =2, §11. 

limbo = 0, §18. 
limit: int, §103. 
loc: location, §74. 


lost-treasures: int, §89. 
min-in-cave = 9, §18. 
oldoldloc: location, §74. 
place: location [], §63. 
printf : int (), <stdio.h>. 
prop: int [], §63. 
tally: int, §89. 
toting = macro ( ), §63. 
true = 1, §2. 


374 Selected Papers on Fun and Gaines 
189. “You’re dead, Jim.” 

When you die, newloc is undefined (often limbo) and oldloc is what 
killed you. So we look at oldoldloc, the last place you were safe. 

We generously allow you to die up to three times; death-count is the 
number of deaths you have had so far. 

#define max-deaths 3 

( Deal with death and resurrection 188 } += 
death: death-count ++■, 
if ( closing ) { 

print f ( " It u looks u as u though u y ou ’ r e u dead . uu \ 

Well , u seeing u as u hou u it ’ s u so u close\n\ 
to u closing u time u anyway >L1 let ’ s u just u call u it u a u day . \n" ); 
goto quit', 

} 

if (-iyes(death-wishes[ 2 * death-count - 2] , death-wishes [2 * death-count - 1], 
ok) V death-count = max-deaths) goto quit', 


DEATH AND RESURRECTION 


Adventure 375 


190. (Global variables 7 ) += 

int death-count; /* how often have you kicked the bucket? 
char * death-wishes [ 2 * max-deaths] = { 

" 0h udear , uyou u seem u to u haveugotten u yourself u killed . uu \ 
I u niight u be u able u to\n\ 


*/ 


help u you u out , u but u I ’ ve u never u really u done u this u bef ore . uu \ 
Do u you u want u me\n\ 
to u try u to u reincarnate u you?" , 

All u right -uuButudon’ t u blame u me u if u something u goes u wr \n\ 

uuuuuuuuuuuuuuuu ljPOOF! !u \n\ 

You u are u engulf ed u in u a u cloud u of u orange u smoke . uu \ 
Coughing u and u gasping,\n\ 
you u emerge u f romutheusmokeyanduf ind . . . . " , 

You u clumsy u oaf , u you ’ ve u done u it u again ! uu \ 

I u don ’ t u know u how u long u I u can\n\ 
keep u this u up . uu \ 

Douyouuwantumeutoutryureincarnatinguyouuagain?" , 
°kay, u now u where u did u I u put u my u resurrection u kit?. . . . uu >P00F ! <\n\ 
Everything u disappears u in u a u dense u clouduOf u orange u smoke. " , 

"Now u you ’ ve u really u done u it ! uu \ 

I ’m u out u of u orange u smoke ! u U You u don’ t u expect\n\ 
me u t o u do u a u de c ent u r e incarnat i on u \ 

without u any u orange u smoke , u do u y ou? " , 

"Okay , u if u you ’ re u so u smart , u do u it u yourself ! UU I ’m u leaving ! " }; 


closing = macro, §177. 
limbo = 0, §18. 
newloc: location, §74. 
ok = macro, §14. 
oldloc: location, §74. 


oldoldloc : location, §74. 
print f: int (), <stdio.h>. 
quit : label, §2. 
yes : void ( ), §71. 


376 Selected Papers on Fun and Games 

191. At this point you are reborn. All objects you were carrying are 
dropped at oldoldloc (presumably your last place prior to being killed), 
with their properties unchanged. The loop runs backwards, so that the 
bird is dropped before the cage. The lamp is a special case, because we 
wouldn’t want to leave it underground; we turn it off and leave it outside 
the building only if you were carrying it, of course. You yourself are 
left inside the building. (Heaven help you if you try to xyzzy back into 
the cave without the lamp.) We zap oldloc so that you can’t just go 
back. 

( Deal with death and resurrection 188 ) +h 
if (toting ( LAMP)) prop [LAMP] = 0; 

place [WATER] = limbo ; place [OIL] = limbo ; /* must not drop them */ 

for (j = max-obj-, j > 0; j — ) 

if (toting (j)) drop(j,j = LAMP ? road : oldoldloc)-, 
loc = oldloc = house ; 
goto commence', 

192. Oh dear, you’ve disturbed the dwarves. 

( Deal with death and resurrection 188 ) += 
dwarves japset-. 

printf ( Theuresultinguruckusuhasuawakenedutheudwarves . uu \ 
There u are u now u several\n\ 

threatening u little u dwarves u in u the u room u with u ycm ! uu \ 

Most u of u them u throw\n\ 
knives u at u you ! uu All u of u them u get u you ! \n" ); 


SCORING 


Adventure 377 


193. Scoring. Here is the scoring algorithm we use: 


Objective 

Points 

Total possible 

Getting well into cave 

25 

25 

Each treasure < chest 

12 

60 

Treasure chest itself 

14 

14 

Each treasure > chest 

16 

144 

Each unused death 

10 

30 

Not quitting 

4 

4 

Reaching Witt’s End 

1 

1 

Getting to closing 

25 

25 

Various additional bonuses 


45 

Round out the total 

2 

2 

Total: 350 


Points can also be deducted for using hints. One consequence of these 
rules is that you get 32 points just for quitting on your first turn. And 
there’s a way to get 57 points in just three turns. 

Full points for treasures are awarded only if they aren’t broken and 
you have deposited them in the building. But we give you 2 points just 
for seeing a treasure. 

#define maxscore 350 

(Global variables 7) += 
int bonus-, 

/* extra points awarded for exceptional adventuring skills * / 


closing = macro, §177. 
commence: label, §75. 
drop: void (), §64. 
house = 3, §18, §25. 
j: register int, §2. 
LAMP =2, §11. 
limbo = 0, §18. 
loc: location, §74. 
max-obj = 66, §11. 


OIL = 25, §11. 
oldloc: location, §74. 
oldoldloc: location, §74. 
place: location [], §63. 
printf : int (), <stdio.h>. 
prop: int [], §63. 
road = 1 , §18, §23. 
toting = macro ( ), §63. 
WATER = 24, §11. 


378 Selected Papers on Fun and Games 

194 . The hints are table driven, using several arrays: 

• hint-count [j] is the number of recent turns whose location is relevant 
to hint j; 

• hint.thresh[j } is the number of such turns before we consider offering 
that hint; 

• hint-cost[j ] is the number of points you pay for it; 

• hint-prompt [j] is the way we offer it; 

• hint[j ] is the hint; 

• hinted[j ] is true after we’ve given it. 

Hint 0 is for instructions at the beginning; it costs you 5 points, but you 
get extra power in the lamp. The other hints also usually extend the 
lamp’s power. Hint 1 is for reading the oyster. And hints 2 through 7 
are for the caveJiint , bird-hint, snake-hint, twist-hint, dark-hint, and 
witt-hint , respectively. 

Here’s the subroutine that handles all eight kinds of hints. 

( Subroutines 6 } += 
void offer ARGS((int)); 
void offer (j) 
int j- 

{ 

if 0 > 1) { 

if (^yes {hint-prompt [j], "uluam u prepared u to u give u you u a u hint , " , 
ok)) return; 

printf ("ut>ut u it u will u cost u you u "/,d|jpoints . uu" , hint-cost [)]); 
hinted[j] = yes("Do u you u want u the u hint?" , hint [y], ok); 

} else hinted [j] = yes {hint-prompt [j], hint[j], ok)-, 
if {hinted[j] A limit > 30) limit += 30 * hint, -cost [j] ; 

195 . ( Check if a hint applies, and give it if requested 195 ) = 
for {j = 2 ,k = cave-hint-, j <7; j++,k += k) 

if {-^hinted [j]) { 

if (( flags[loc ] & k) = 0) hint-count[j ] = 0; 
else if {++ hint-count [j] > hint-thresh[j ]) { 
switch {j) { 

case 2: if {prop [GRATE] = 0 A ->here (KEYS)) break; 
else goto bypass-, 

case 3: if (/tere(BIRD) A oldobj = BIRD A toting (ROD)) break; 
else continue; 

case 4: if (/lere(SNAKE) A -./lere(BIRD)) break; else goto bypass-, 
case 5: if {first[loc] = 0 A first[oldloc] = 0 A first[oldoldloc] = 

0 A holding > 1) break; 


SCORING 


Adventure 379 


else goto bypass-, 

case 6: if (prop [EMERALD] / — 1 A prop [PYRAMID] = -1) break; 

else goto bypass ; 
case 7 : break ; 

} 

offer (j); 

bypass : hint-Count[j] = 0; 

} 

} 

This code is used in section 76. 


ARGS = macro ( ), §3. 

BIRD = 10, §11. 
bird-hint = 16, §20. 
cave-hint =8, §20. 
dark-hint — 128, §20. 
EMERALD =60, §11. 
first: object [], §63. 
flags: int [], §20. 

GRATE = 3, §11. 
here = macro ( ), §74. 
hint: char *[], §196. 
hint-cost: int [], §196. 
hint-count: int [], §196. 
hint-prompt: char *[], §196. 
hint-thresh: int [], §196. 
hinted: boolean [], §196. 
holding: int, §63. 
j: register int, §2. 


k: register int, §2. 

KEYS = 1, §11. 
limit: int, §103. 
loc: location, §74. 
ok = macro, §14. 
oldloc: location, §74. 
oldobj: object, §77. 
oldoldloc: location, §74. 
printf: int (), <stdio.h>. 
prop: int [], §63. 

PYRAMID = 61, §11. 

ROD =6, §11. 

SNAKE = 13, §11. 
snake-hint = 32, §20. 
toting = macro (), §63. 
twist-hint = 64, §20. 
witt-hint = 256, §20. 
yes: void ( ), §71. 


380 Selected Papers on Fun and Games 
196. #define nJiints 8 
( Global variables 7 ) += 

int hint-count [n,-hints]; /* how long you have needed this hint */ 

int hintJhresh[nJiints] = {0,0,4,5,8,75,25,20}; 

/* how long we will wait */ 
int hint-cost\nJiints ) = {5, 10, 2, 2, 2, 4, 5, 3}; 

/ * how much we will charge * / 
char * hint-prompt [n-hints] = { 

Welcome u to u Adventure ! ! uu Would u you u like u instructions?" , 

"Hmimn , u this u looks u like u a u clue , u \ 

which u means u it ’ll u cost u you u 10 u points u to\n\ 
read u it ■uuShould u I u go u ahead u and u read u ituarLyway? M , 

" Are u y ou u try ing u t o u get u into u the u cave?" , 

" Are u you u try ing u t o u catch u the u bird?" , 
"Are u you u trying u to u deal u somehow u with u the u snake?" , 
"Do u you u need u help u getting u out u of u the u maze?" , 
"Are u you u trying u to u explore u beyond u the u Plover u Room?" , 
"Do u you u need u help u getting u out u of u here?" }; 
char *hint [n-hints] = { 

"Somewhere u nearby u is u Colossal u Cave , u \ 

where u others u have u f ound u f ortunes u in\n\ 
treasure u and u gold , u \ 

thoughuit u is u rnmored u that u some u whOuenter u are u never\n\ 
seen u again . uuMagic u is u said u to u work u in u the u cave . u \ 
u IuWillube u your u eyes\n\ 

and u hands . uuDirectumeuWith u comraandsuOf u one u or u twouWords . uu 
I u should\n\ 

warn u you u that u I u look u at u only u \ 

the u f irst u f ive u letters u of u each u word, u so\n\ 
you > ll u have u to u enter u \ "NORTHEASTS " u as u \ "NE\ " u \ 
to u distinguish u it u from\n\ 

\ "NORTHS " . uuShould u you u get u stuck , U S 

type u S "HELPS " u f or u some u general u hints . SnS 
For u inf ormation u on u how u to u end u your u adventure , u etc . , U S 
ty P e u S"INF0S" . SnS 
uuuuuuuuuuuuuuuuuuuuuuu”uu'uu"\n\ 

The u f irst u adventure u prograiHuwas u S 
developed u by u Willie u Crowther . SnS 
Most u of u the u f eatures u of u the u current u program u were u S 

added u by u Don u Woods ; SnS 
all u of u its u bugs u wereuaddeduby u Don u Knuth. " , 

"It u says , u S"There u iSuSomethinguStrange u about u this u place , U S 
such u that u oneSnS 

of u the u words u I ’ ve u always u known u now u has u a u new u ef f ect . S " " , 


SCORING 


Adventure 381 


"The u grate u is u very u solid u and u has u a u hardened u steel u lock. uu \ 
You u cannot\n\ 

enter u without u a u key , uand u there u are u no u keys u in u sight . uu \ 
I u would u recommend\n\ 
looking u elsewhere u f or u the u keys . " , 
"Something u seems u to u be u frightening u the u bird u just u now u \ 
and u you u cannot\n\ 

catch u it u no u matter u what u you u try , u \ 
u Perhaps u you u might u try u later . " , 

" You u can ’ t u kill u the u snake , u or u dr ive u it u away , u \ 
or u avoid u it , u or u anything\n\ 
like u that . U uThere u is u a u way u to u getuby , u \ 
but u you u don’ t u have u the u necessary\n\ 
resources u right u now. " , 

" You u can u make u the u passages u look u less u alike u by u dropping u things . " , 
"There u is u auway u to u explore u that u region u \ 
without u having u to u worry u about\n\ 
f alling u into u a u pit . uu \ 

None u of u the u objects u available u is u immediately\n\ 
useful u f or u discovering u the u secret . " , 

"Don’t u go u west . " }; 

boolean hinted [ri-hints]; /* have you seen the hint? */ 


boolean = enum, §2. 


382 Selected Papers on Fun and Games 

197 . Here’s a subroutine that computes the current score 
( Subroutines 6 ) += 
int score ARGS((void)); 
int score ( ) 

{ 

register int j, s = 2; 
register object k; 

if (dflag) s += 25; /* you’ve gotten well inside */ 

for (k = min.treasure ; k < max-obj; k++) { 
if ( prop[k ] > 0) { 
s -f~= 2; 

if ( place [fc] = house A prop [k] = 0) 

s += {k < CHEST ? 10 : k = CHEST ? 12 : 14); 

} 

s += 10 * ( max-deaths - death-count)-, 
if (-i gave-up ) s += 4; 

if (place [MAG] = witt) s++; /* proof of your visit */ 

if ( closing ) s += 25; 
s += bonus-, 

for ( j = 0; j < nJiints-, j++) 
if (hinted [j]) s — — hint-cost[j]\ 

return s; 

} 


198 . The worst possible score is -3. 
earn exactly 1 point. 

#define highest-class 8 


It is possible (but unusual) to 


( Print the score and say adieu 198 ) = 
k = score ( ); 

pnni/("You L1 scored u , /.d u point , /.s u out LJ of u aupossible u 7.d, u \ 

usinguXduturnXs . \n" ,k,k = 1? "" ; " s ", maxscore, turns 
turns = 1 ? : " S "); 

for ( j = 0; classscore[j ] < k\ j++) ; 
print/ ("/ s\n\ 


To u achieve u the u next u higher u rating" , class-message\j])- 
if (j < highest-class) print/ (”, u you u need u "/„d u more u polnt7.s . \n" , 
classscore[j ] — k, class score [j] = k + 1 ? "" : » 8 »). 
else print/ ("uWould u be u a u neat u trick ! \n\ 

Congratulations ! ! \n" ); 

This code is used in section 2. 


LAUNCHING THE PROGRAM 


Adventure 383 


199 . {Global variables 7) += 

int classscore[] = {35,100,130,200,250,300,330,349,9999}; 
char *class-message [ ] = { 

" You uare u obviously LJ a u rank u amateur . U uBetter u luck u next u time . " , 
Your u score u qualif ies u you u as u a u novice u class u adventurer . " , 
You u have u achieved u the u rating u \"Experienced u Adventurer\" . 11 . 
You u may u now u cons ider u y our self u a u \"Seasoned u Adventurer\" . " , 
"You u have u reached u \" Junior u Master\" u status . " , 
"Your u score u puts u you u in u Master u Adventurer u Class u C. " , 
"Your u score u puts u you u in u Master u Adventurer u Class u B . " , 
"Your u score u puts u you u in u Master u Adventurer u Class u A . " , 

" Alluof u Adventuredom u gives u tribute u to u you , u \ 
"Adventure u Grandmaster ! " }; 

200. Launching the program. The program is now complete; all 
we must do is put a few of the pieces together. 

Most of the initialization takes place while you are reading the opening 
message. 

( Initialize all tables 200 } = 

(Initialize the random number generator 156); 

offer ( 0 ); /* Give the welcome message and possible instructions */ 

limit = (hinted [Q\ ! 1000 : 330 ); /* set lifetime of lamp */ 

( Build the vocabulary 10 ) ; 

(Build the travel table 23); 

(Build the object tables 69 ); 

oldoldloc = oldloc = loc = newloc = road; 

This code is used in section 2. 


ARGS = macro ( ), §3. 
bonus: int, §193. 

CHEST = 56, §11. 
closing = macro, §177. 
death-count: int, §190. 
dftag: int, §159. 
gave-up: boolean, §96. 
hint-cost : int [], §196. 
hinted: boolean [], §196. 
house = 3, §18, §25. 
j: register int, §2. 
k: register int, §2. 
limit: int, §103. 
loc: location, §74. 

MAG = 19, §11. 
max-deaths = 3, §189. 


max-obj = 66, §11. 
maxscore = 350, §193. 
min-treasure = 51, §11. 
nJiints = 8, §196. 
newloc: location, §74. 
object =enum, §11. 
offer: void (), §194. 
oldloc: location, §74. 
oldoldloc: location, §74. 
place: location [], §63. 
printf : int (), <stdio.h>. 
prop: int [], §63. 
road = 1, §18, §23. 
turns: int, §77. 
witt = 67, §18, §44. 


384 Selected Papers on Fun and Games 

201. Index. A large cloud of green smoke appears in front of you. 
It clears away to reveal a tall wizard, clothed in grey. He fixes you with 
a steely glare and declares, “This adventure has lasted too long.” With 
that he makes a single pass over you with his hands, and everything 
around you fades away into a grey nothingness. 


abovep : 18, 45, 48. 

abover: 18, 52, 53. 

ABSTAIN: 13, 76, 82, 128. 

ACROSS: 9,10,34,46,55,57. 
action: 13, 77. 
action-type : 5, 14, 78, 97. 

alcove : 18, 50, 51, 149. 

alLalike : 21, 36. 
ante: 18,42,44,45,70. 
arch: 18, 43. 

ARCS: 3,6,8,64,65,66,71,72, 
154, 160, 194, 197. 

ART: U, 12, 70. 
attack: 164, 165, 167, 170. 
attack-msg: 170, 171 . 
awk: 18, 31, 91. 

AWKWARD: 9, 10. 

AXE: 11, 12, 70, 122, 123, 129, 
162, 163, 179. 

BACK: 9, 10, 140. 
barr: 18, 57, 70, 132. 

BARREN: 9, 10, 57. 
base: 63, 66, 67, 88, 94, 101, 112, 
121, 123, 128, 129, 132, 133, 
151, 174, 179. 

BATTERIES: 11, 12, 70, 118, 184, 
186. 

BEAR: 11,12,70,86,94,98,112, 
117, 122, 123, 125, 126, 129, 
133, 151, 179. 

BED: 9, 10, 28. 

bedquilt : 18, 42, 44, 45, 48, 52. 

BEDQUILT: 9, 10, 42, 48. 

BIRD: 11, 12, 70, 98, 112, 114, 
117, 120, 125, 126, 127, 129, 
181, 195. 

bird: 18, 31, 37, 70, 91. 
bird-hint: 20, 31, 194. 

BLAST: 13, 14, 79, 99. 
block: 18, 47. 


bonus: 99, 181, 193, 197. 
boolean: 2, 66, 71, 84, 96, 159, 
160, 177, 185, 196. 

BOTTLE: 11, 12, 70, 90, 100, 104, 
106, 107, 110, 112, 113, 115, 
181. 

bottle-empty: 104, 110, 112, 115. 
boulders: 18, 54. 
branch: 78, 97. 

BREAK: 13, 14, 101. 

BRIDGE: 11, 12, 55, 69. 119, 124, 
151, 152, 179. 

BRIDGE_ : 11, 69, 119, 124, 152, 

179. 

bridge-rmk: 21, 34, 55, 57. 

BRIEF: 13, 14, 86, 87, 95. 
brink: 18, 36, 37, 56. 

BROKEN: 9, 10, 41. 

Brucker, Roger W.: 45. 

bufsize: 71,72,73. 
buffer: 71, 72, 73. 
bypass : 195 . 

CAGE: 11, 12, 70, 112, 114, 117, 
130, 181. 

CALM: 13, 14, 129. 
cant: 18, 32, 61. 
cant-see-it: 79, 90, 135. 

CANYON: 9, 10, 31, 45. 
carry: 65, 112, 174. 

CAVE: 9, 10, 140. 
cave-hint: 20, 29. 194, 195. 
CAVERN: 9, 10, 47, 50, 51. 

CHAIN: 11, 12, 63, 70, 88, 93, 112, 
130, 131, 132, 133, 151, 179. 
chamber: 18, 57, 70. 
change.to: 79, 113, 122, 129. 
check: 18, 46, 61. 
cheese: 18, 45, 46, 50, 54. 

CHEST: 11, 12, 70, 172, 173, 197. 
chest-loc: 159, 173, 174. 


INDEX 


Adventure 385 


CLAM: !!, 12, 43, 70, 93, 98, 125, 
126, 130, 134. 
clam-oyster: 134 . 
class-message : 198, 199 . 

classscore: 198, 199 . 
clean: 18, 42. 
climb: 18, 46, 61. 

CLIMB: 9, 10, 35, 37, 42, 46, 47, 
48, 52. 

clockl : 177. 178, 179. 
clock2 : 177, 178, 179, 180, 181. 
CLOSE: 13, 14, 93, 130, 134. 
closed: 88, 93, 99, 100, 101, 120, 
125, 127, 129, 135, 177, 181, 
182. 

closing: 99, 131, 153, 157, 177, 
179, 189, 193, 197. 

COBBLES: 9,10,30,31. 
cobbles: 18, 30, 31, 70, 91. 

COINS: 11, 12, 70, 117, 118. 
Colossal Cave: 18, 41, 45, 196. 
command-type: 77, 78. 
commence: 75, 102, 191. 
complex: 18, 42, 43, 44, 45, 159. 
cond: 19, 21, 147, 166. 
corr: 18, 57. 
crack: 18, 31, 59. 

CRACK: 9, 10, 31. 
crawl: 18, 48. 

CRAWL: 9, 10, 30, 31, 35, 38, 42, 
48, 50, 54, 57, 148. 
cross: 18, 38, 40, 56. 

CROSS: 9, 10, 34, 55, 57. 
Crowther, William R.: 1 , 25, 41, 

45, 196. 
cry : 125 . 

CRYSTAL: 11, 12, 34, 69, 99, 179. 
CRYSTAL.: 11, 69. 
current-type: 6, 7, 10, 12, 14, 16. 
cycle: 76, 78, 79. 

D: 9, 10, 23, 24, 26, 27, 28, 29, 
31, 32, 36, 37, 38, 39, 41, 42, 
43, 44, 45, 46, 47, 48, 52, 53, 
55, 57, 58. 

DARK: 9, 10, 31, 51. 
dark: 84, 85, 86, 93, 102, 135. 
dark-hint: 20, 51, 194. 
dead-end: 21, 39, 56. 


deadO: 18,40,56. 
deadl : 18, 36, 56. 

dead2 : 18,36,56,159. 

dead3: 18, 36, 56. 
dead4 : 18, 36, 56. 

dead5: 18, 36, 56. 
dead6: 18,36,56. 
dead?: 18, 36, 56. 
dead8 : 18, 37, 56. 

dead9 : 18,36,56. 
deadlO: 18,36,56. 
deadl 1: 18,36,56. 

death: 86, 151, 170, 189 . 
death-count: 189, 190 . 197. 
death-wishes: 189, 190 . 

DEBRIS: 9, 10, 30, 31. 
debris: 18, 25, 30, 31, 70, 91. 
default-msg: 14, 15, 57, 79, 98, 

111, 129, 139, 148. 
default-to: 79, 83, 99, 100, 106, 

112, 117, 130, 139. 
DEPRESSION: 9, 10, 23, 26, 28, 

31, 91. 

dest: 19, 21, 143, 146, 147, 166. 
destroy: 65, 98, 118, 119, 120, 
124, 127, 128, 129. 134, 152, 
179, 181. 

dflag: 90, 129, 159, 160, 161, 162, 
167, 170, 197. 

DIAMONDS: 11, 12, 70. 
didit: 18, 61. 
diffO: 18,38,39. 
diffl : 18, 39. 

diffS: 18,39. 
diffS: 18, 39. 
diff4 : 18, 39. 

diff5 : 18,39. 

diff 6: 18, 39. 

diff 7: 18, 39. 

diff 8: 18,39. 
diff 9 : 18,39. 

diff 10 : 18,39. 
dirty: 18, 41, 42. 
ditto: 21, 23, 24, 25, 26, 27, 28, 
29, 30, 31, 32, 33, 34, 35, 36, 
37, 38, 39, 40, 41, 42, 43, 44, 
45, 46, 47, 48, 50, 51, 52, 53, 
54, 55, 56, 57. 


386 Selected Papers on Fun and Games 


dkill: 159, 163. 

dloc : 159, 160, 162, 163, 164, 166, 

167, 172, 173, 179. 

DOME: 9, 10, 32. 

DOOR: 11, 12, 47, 70, 93, 107, 109, 
130. 

DOWNSTREAM: 9, 10, 23, 25, 26, 

28, 42. 

DRAGON: 11, 12, 52, 53, 69, 98, 

120, 122, 125, 126, 128, 129. 
DRAGON,: 11, 69, 128. 

DRINK: 13, 14, 79, 106. 
droom: 18, 51, 70, 172. 
drop: 64, 65, 67, 101. 117, 118, 
119, 122, 123, 124, 132, 134, 
150, 151, 162, 163, 174, 186, 

191. 

DROP: 13, 14, 99, 111, 117, 122. 
dseen: 159, 163, 164, 173, 176, 

179. 

dtotal : 164, 165. 167. 170. 

duck: 18, 35, 61. 
dusty: 18, 42, 45. 
dwarf: 90, 92, 100, 122, 126, 159, 
160 . 

DWARF: 11, 12, 70, 90, 98, 100, 

101, 125, 126, 129, 181. 
dwarves-upset: 101, 120, 125, 

192 . 

E: 9, 10, 23, 24, 26, 27, 28, 29, 31, 
32, 34, 35, 36, 37, 38, 39, 40, 

41, 42, 44, 45, 46, 47, 51, 53, 

54, 56, 57. 

EAT: 13, 14, 57, 92, 98, 106, 129. 
efiss: 18, 32, 34, 69, 99. 

EGGS: 11, 12, 70, 139. 
elong: 18, 35, 38, 40. 

EMERALD: 11, 12, 41, 51, 70, 149, 
150, 195. 

Emerson, Ralph Waldo: 26. 
emist: 18, 31, 32, 33, 34, 40, 41, 

61, 69, 88. 

ENTER: 9, 10, 23, 25, 29, 47, 57. 

ENTRANCE: 9, 10, 31, 91. 

epit: 18, 46. 

exit: 2, 62. 

e2pit: 18, 45, 46, 69. 

falls: 18, 47, 70. 


false: 2, 66, 71, 141, 160, 173. 
fbarr: 18, 57. 

FEED: 13, 14, 122, 129. 

FEEFIE: 13, 14, 97, 136. 
fflush: 71, 72. 
fgets: 2, 71, 72. 

FILL: 13, 14, 79, 110, 113. 

FIND: 13, 14, 79, 90, 100, 148. 
first: 63, 64, 65, 88, 92, 195. 
flags: 20, 21, 74, 84, 110, 195. 
FLOOR: 9, 10, 42. 
foobar: 136, 137, 138, 139. 

FOOD: 11, 12, 70, 92, 98, 122, 129. 
FORCE: 59, 60, 61. 
forced-move: 59, 86, 143, 146, 

176. 

forest: 18, 23, 24, 26, 27, 28, 29. 
fork: 18, 57. 

FORK: 9, 10, 57. 

FORWARD: 9, 10, 24, 27, 32, 34, 

40, 53, 148. 
found : 143 . 

gave.up: 95, 96, 197. 
get-object: 79, 92, 93, 106, 107, 
110, 126. 

GEYSER: 11, 12, 70. 
giant: 18, 47, 70, 139. 

GIANT: 9, 10, 47. 

Gilbert, John Russell: 57. 
give-up: 95, 184. 

GO: 13, 14, 79, 83. 
go-forAt: 75, 143. 

GOLD: 11,12,31,32,70,88. 

GRATE: 11, 12, 29, 30, 31, 63, 69, 
90, 91, 93, 130, 131. 179, 181, 
195. 

GRATE _ : 11,63,69,93. 

grate-rmk: 21, 29, 30, 58. 

GULLY: 9, 10, 23, 29. 
h: 6, 8. 

HALL: 9, 10, 32, 33, 34, 40, 41, 43. 
hash_entry: 5, 7. 
hash-prime: 6, 7, 8. 
hash-table: 6, 7, 8, 76, 78, 79, 

97, 105. 

here: 74, 84, 90, 92, 93, 99, 102, 
106, 110, 113, 117, 120, 122, 


INDEX 


Adventure 387 


126, 129, 130, 139, 172, 184, 
187, 195. 

highesLclass: 198 . 
hill : 18, 23, 24. 

hint: 194, 196 . 
hint-cost : 194, 196 . 197. 

hint-count: 194, 195, 196 . 
hint-prompt: 194, 196 . 
hintJhresh: 194, 195, 196 . 
hinted: 135, 194, 195, 196, 197, 
200 . 

hmk: 18,32,40,41,53,61,70, 
120, 127, 159. 

holding: 63, 64, 65, 112, 149, 195. 
holds: 21,31,32,41,43,51. 

HOLE: 9, 10, 38, 41, 42, 46. 
house: 18, 23, 25, 31, 41, 61, 70, 
178, 191, 197. 

HOUSE: 9, 10, 23, 24, 26, 28, 29. 
i: 164 . 

immense: 18, 47, 70. 

IN: 9, 10, 23, 29, 30, 31, 57, 148. 
incantation: 136, 137 . 
inhand: 18, 63, 65, 104, 110, 112. 
inside: 18, 29, 30, 31, 69. 
instruction: 19, 20, 22. 
interval: 86, 87, 95. 
intransitive: 76, 78, 79 . 
INVENTORY: 13, 14, 79, 90, 94, 

100, 148. 

is-atJoc: 66, 90, 100, 117, 120, 
122, 126, 147. 
isJreasure: 1J., 67, 122. 
isspace: 2, 72. 
j: 2, 160, 194, 197 . 

JEWELS: 11,12,70. 
jumble: 18, 32, 41. 

JUMP: 9, 10, 34, 41, 47, 48, 49, 

55, 57. 

k: 2, 6, 197. 

KEYS: n, 12, 29, 63, 70, 130, 195. 
KILL: 13, 14, 79, 122, 125. 

KNIFE: 11, 12, 70, 90. 
knife Joe : 90, 167, 168, 169. 

Knuth, Donald Ervin: 1, 196. 

L: 9, 10, 32, 40, 57, 148. 

1 : 64, M, 144 . 


LAMP: 11, 12, 70, 84, 99, 102, 172, 
181, 184, 187, 191. 

Levy, Steven: 23, 55. 
lighted: 20, 23, 24, 25, 26, 27, 28, 
29, 30, 31, 51, 57, 58, 84. 
likel : 18, 35, 36. 

like 2: 18,36. 

Iike3: 18, 36, 56, 159. 

Iike4 : 18, 36, 48, 56. 

Hke5: 18, 36. 

Iike6: 18, 36, 48. 
like 7: 18, 36. 

Iike8: 18,36,56. 

Hke9 : 18,36,48,56. 

likelO: 18,36,37,56. 
likel 1: 18,36,56. 

Iikel2: 18,36,37,56. 
likel 3: 18, 36, 37, 56. 

Hkel4 '■ 18, 36. 

limbo: 18, 60, 63, 65, 69, 70, 86, 

106, 107, 115, 124, 139, 153, 
161, 162, 163, 164, 169, 172, 
179, 184, 189, 191. 

lime: 18, 57. 

limit: 102, 103, 183, 184, 186, 

187, 194, 200. 
link: 63, 64, 65, 88, 92. 

liquid: 20, 23, 25, 26, 28, 42, 46, 
47, 52, 74. 
list: 3. 

listen: 72, 76, 128. 

II: 143, 144. 

loc: 59, 66, 74, 75, 84, 86, 88, 90, 
91, 92, 93, 99, 100, 101, 105, 

107, 110, 117, 118, 121, 122, 
123, 128, 132, 134, 139, 140, 
141, 143, 146, 148, 149, 150, 
151, 153, 157, 160, 161, 162, 
163, 164, 167, 169, 170, 172, 
174, 176, 178, 181, 184, 186, 

188, 191, 195, 200. 
location: 18, 19, 21, 63, 64, 65, 

74, 144, 159, 165. 
long.desc: 20, 21, 23, 53, 61, 86. 
LOOK: 9, 10, 86, 140. 
look-count: 95, 141, 142. 
lookup: 8, 78, 97, 105. 
loop.rmk: 21, 44, 45. 


388 Selected Papers on Fun and Games 


lose: 18, 34, 55, 60. 
lost-treasures: 88, 89, 120, 127, 
129, 151, 172, 183. 
low: 18, 45, 47, 48, 50, 55. 

LOW: 9, 10, 31. 

m: 6 . 

MAG: 11, 12, 70, 93, 135, 197. 
main: 2. 

makeJnst: 21, 23, 24, 25, 26, 27, 
28, 29, 30, 31, 32, 33, 34, 35. 
36, 37, 38, 39, 40, 41, 42, 43, 
44, 45, 46, 47, 48, 49, 50, 51, 
52, 53, 54, 55, 56, 57, 58, 59, 
60, 61. 

make Joe: 21, 23, 24, 25, 26, 27, 
28, 29, 30, 31, 32, 33, 34, 35, 
36, 37, 38, 39, 40, 41, 42, 43, 
44, 45, 46, 47, 48, 49, 50, 51, 
52, 53, 54, 55, 56, 57, 58, 59, 
60, 61. 

Makholm, Henning: 91. 
max-deaths: 189, 190, 197. 
maxJoc: 18, 19, 20, 63, 143, 146. 
max-obj : 11, 63, 66, 94, 128, 172, 

174, 181, 182, 191, 197. 
max-pirateJoc: 56, 161, 166 172 
176. 

maxscore: 95, 193, 198, 
maxspec: 18, 19, 21, 146. 
McCarthy, John: 1. 
meaning: 5, 6, 76, 78, 79, 97, 105. 
mess-wd: 16. 

MESSAGE: 11, 12, 70, 93, 135, 172, 
173. 

message: 16, 17, 79, 99. 
messageJoc: 159, 173. 
message-type: 5, 16, 76, 78. 
min-forcedJoc: 18, 59, 166. 
min-in-cave: 18, 140, 153, 184. 
minJowerJoc: 18, 91, 161, 164 
166, 178. 

minJreasure: 11, 172, 174, 197. 
MIRROR: 11, 12, 69, 70, 101, 181. 
mirror: 18, 49, 52, 70. 

MIRROR, : 11,69,181. 

misty: 18, 50, 51. 

MOSS: 11, 12, 70. 


mot: 19,21,76,77,78,140,143, 
146, 148. 

motion: 9, 19, 77. 

motion-type: 5, 10, 78. 
move: 65, 119, 123, 124, 128, 139, 
152, 173, 179, 181. 
move-chest: 173, 175. 

N: 9, 10, 23, 24, 26, 27, 28, 29, 32, 
33, 34, 35, 36, 37, 38, 39, 40, 
41, 42, 44, 45, 47, 48, 50, 52, 
53, 54, 57. 
n: 71. 

n-hints: 196, 197. 

nadasucede: 136, 139 . 

name: 63, 67, 94. 

narrow: 18, 47, 61. 

nd: 159, 160, 162, 163, 164. 176. 

179. 
ne: 39. 

NE: 9, 10, 39, 44, 45, 51, 55, 57, 

58. 

neck: 18, 31, 41, 47, 49, 60. 
neend: 18, 58, 99, 181. 
neside: 18, 57, 69, 119, 124, 151 
152, 179. 
new-mess: Hi. 
new-note: 67, 69, 70. 
new-obj: 67, 69, 70. 
new-word: 6, 10, 12, 14, 16. 
newloc: 74, 75, 86, 140, 146, 148, 
149, 151, 153, 166, 176, 189, 
200 . 

no-good: 146, 147. 
noJiquid-here: 74, 110, 111. 
nojype: 5. 

not: 21, 29, 30, 31, 34, 40, 46, 47 
52, 53, 55, 61. 

note: 63, 67, 88, 99, 108, 118, 

121, 128, 139, 152, 182. 
note-ptr: 63, 67. 

NOTHING: 11, 63, 66, 76, 94, 97, 

106, 107, 110, 122, 125, 128, 

129, 133, 174, 179. 

NOWHERE: 9, 10, 31, 78, 140. 
ns: 18, 40, 41, 42, 70. 
nugget: 18, 32, 33, 70, 162. 
nw: 39. 

NW: 9, 10, 36, 39, 44, 45, 51. 


INDEX 


Adventure 389 


obj : 76,77,78,90,92,93,97,98, 
99, 100, 101, 106, 107, 108, 

109, 110, 112, 113, 115, 117, 
122, 124, 125, 126, 128, 129, 
130, 131, 134, 135. 

object: 11,63,64,65,66,68, 

77, 88, 197. 

Object-oriented programming: 11. 
object-in-bottle : 90, 100, 113, 115. 

object-type: 5, 12, 78. 
odloc: 159, 162, 164, 166, 167, 

172, 173, 176. 

OFF: 13, 14, 79, 102. 
offer: 135, 194, 195, 200. 

OFFICE: 9, 10. 

offset: 63, 67, 88, 99, 108, 118, 
121, 128, 139, 152, 182. 
oil: 20,46,74,110. 

OIL: Id, 12, 70, 90, 100, 107, 109, 

110, 112, 115, 191. 
oiLhere: 74, 90. 100. 
ok: 14, 95, 189, 194. 

olclloc: 74, 75, 143, 181, 189, 191, 
195, 200. 

oldobj: 76,77,195. 
oldoldloc: 74, 75, 143, 151, 170, 
188, 189, 191, 195, 200. 
oldverb: 76, 77, 79, 126. 

ON: 13, 14, 79, 102. 

OPEN: 13, 14, 93, 130, 131, 132. 
oriental: 143, 45, 48, 50, 70. 
ORIENTAL: 9, 10, 45, 48, 50. 

OUT: 9, 10, 25, 30, 31, 33, 39, 40, 
41, 42, 43, 45, 46, 47, 48, 51, 
52, 53, 56, 57, 148. 

OUTDOORS: 9,10,25. 
outside: 18, 23, 26, 28, 29, 30, 

31, 69. 

OVER: 9, 10, 34, 55, 57. 

OYSTER: U, 12, 43, 70, 93, 98, 

125, 126, 130, 134, 135, 181, 
182. 

P- 2,6,8,72. 
panic: 177 . 180. 
parse : 76 . 

PASSAGE: 9, 10, 31, 32, 35, 42, 47, 
48, 51, 57. 

pet: 86, 147, 157, 161, 162, 172. 


pdrop: 18, 41, 51, 62, 146, 150. 
PEARL: 11, 12, 70, 134. 

PILLOW: 11, 12, 70, 121, 181. 
PIRATE: 11, 12, 70. 
pirate-notspotted: 172 , 173. 

PIT: 9, 10, 30, 31, 32, 42, 46. 
pitch-dark: 86, 188 . 
pitch-dark-msg : 86, 87, 102. 

place: 63, 64, 65, 66, 74, 93, 100, 
104, 105, 106, 107, 110, 112, 
115, 120, 121, 123. 127, 128, 
139, 151, 172, 174, 184, 191, 
197. 

PLANT: 11, 12, 46, 61, 63, 70, 90, 

107, 108, 112, 181. 

PLANT2: 11, 69, 90, 108. 

PLANT2_ : 11, 69. 

ploc: 164, 165, 166. 

PLOVER: 9, 10, 41, 51, 97. 

PLUGH: 9, 10, 25, 41, 97, 148. 

pony: 18, 39, 70, 159. 

PONY: 11, 12, 70, 117. 

POUR: 13, 14, 79, 107. 

ppass: 18, 51, 62, 146. 
pre-parse: 76, 128. 
printf : 2, 62, 71, 72, 78, 79, 80, 

86, 88, 94, 95, 97, 99, 101, 102, 

108, 110, 111, 119, 120, 121, 

122, 128, 134, 140, 141, 143, 
145, 146, 148, 149, 151, 152, 
157, 162, 163, 170, 172, 173, 
175, 176, 179, 180, 181, 182, 
184, 186, 187, 188, 189, 192, 
194, 198. 

proom: 18, 41, 51, 70, 149, 172. 
prop: 19, 21, 63, 67, 84, 88, 90, 

99, 101, 102, 104, 106, 107, 

108, 109, 110, 112, 114, 115, 
117, 118, 119, 120, 121, 122, 

123, 125, 126, 127, 128, 129, 
130, 131, 132, 133, 139, 147, 
151, 152, 172, 178, 179, 181, 
182, 184, 186, 187, 191, 195, 
197. 

prototypes for functions: 3. 
PYRAMID: 11, 12, 70, 172, 195. 
q: 22, 71, 72. 
qq: 22, 143, 147. 


390 Selected Papers on Fun and Games 


quit : 2, 75, 95, 99, 189. 

QUIT: 13, 14, 95. 

R: 9, 10, 40, 57, 148. 
r: 65. 

ragged: 18, 43. 

ran: 154, 157, 158, 162, 163, 164, 

167. 

range : 154 . 

READ: 13, 14, 93, 135. 

RELAX: 13, 14, 79, 112. 117. 130, 
139. 

rem-count: 20, 21, 62. 
remsize: 20, 62. 
remark: 21, 28, 29, 34, 43, 44, 46, 
47, 53, 55, 57. 
remarks: 19, 20, 21, 146. 
report: 79, 83, 90, 93, 94, 95, 98, 
99, 100, 101, 102, 106, 107, 

108, 109, 110, 111, 112, 113, 
114, 118, 120, 123, 124. 125, 
127, 129, 130, 131, 132, 133, 
134, 135, 136, 139. 
report-default: 79, 98, 99, 100, 

101, 102, 106, 107, 110, 112, 
117, 122, 125, 129, 130, 135. 
res: 18, 52. 

RESERVOIR: 9, 10, 52. 

road: 18, 23, 24, 25, 26, 27, 28, 

29, 91, 178, 191, 200. 

ROAD: 9, 10, 23, 24, 27. 

ROCK: 9, 10, 28. 

ROD: 11, 12, 70, 90, 99, 114, 117, 
122, 181, 195. 

R0D2: 11, 70, 90, 99, 117, 122, 

181. 

ROOM: 9, 10, 42. 

RUB: 13, 14, 99. 

RUG: 11, 12, 63, 69, 88, 128. 

RUG_ : 11,69,128. 

rx: 154, 155. 156. 

S: 9, 10, 23, 24, 26, 27, 28, 29, 

32, 35, 36, 37, 38, 39, 40, 41, 

43, 44, 45, 47, 48, 50, 51, 52, 

54, 56, 57. 
s: 65, 197. 
sac: 18, 43, 134. 

SAY: 13, 14, 78, 82, 97. 


sayit: 21, 28, 29, 34, 43, 44, 46, 
47, 53, 55, 57. 

scant : 18, 52, 53, 69, 128, 166. 
scan2: 18, 52, 53, 128, 166. 
scan3: 18, 53, 69, 128. 166. 
score: 95, 197 . 198. 

SCORE: 13, 14, 95. 
scorr: 18, 48, 55. 
se: 39. 

SE: 9, 10, 39, 44, 48, 50, 56, 57. 
SECRET: 9, 10, 40. 
secret: 18, 40, 53, 54. 
sees: 21, 40, 55, 57. 
sewer: 18, 25, 61. 

SHADOW: U, 12, 69. 

SHADOW,: U, 69. 
shell: 18, 42, 43, 70. 

SHELL: 9, 10, 42, 43. 
shift: 76, 78, 83. 
shorLdesc: 20, 21, 27, 49, 86. 
SILVER: n, 12, 70, 178. 
sjunc: 18, 45, 48, 49. 
slab: 18, 45, 46, 52. 

SLAB: 9, 10, 45, 46, 52. 

slit: 18, 26, 28, 29, 91. 

SLIT: 9, 10, 28, 42. 

slit-rmk: 21, 28, 42. 
smash: Un, 111. 

SNAKE: U, 12, 40, 63, 70, 98, 120, 
125, 126, 127, 129, 181, 195. 
snake-hint: 20, 40, 194. 
snaked: 18, 40, 61. 
soft: 18, 45, 70, 117. 
south: 18, 40, 70. 
speakit: 76, 78, 79. 

SPICES: U, 12, 70. 151. 
spit: 18, 30, 31, 32, 59, 69, 91. 
STAIRS: 9, 10, 32, 40. 

STALACTITE: U, 12, 70. 
start: 20, 21, 62, 143, 146, 166. 
stay: M6, 149, 152. 
stay-put: 78, 108, 122, 128, 163, 
181. 

STDC : 3. 

stdin: 71, 72. 
stdout: 71, 72. 
steep: 18, 47. 

STEPS: 9, 10, 31, 32. 


INDEX 


Adventure 391 


stick-. 164, 165, 167. 170. 
strcpy: 2, 6, 76, 97, 105. 

STREAM: 9, 10, 23, 25, 28, 42. 
streq: 8, 80, 83, 105, 128, 136. 
strncmp-. 2, 8. 

SURFACE: 9, 10, 31. 
sw: 39. 

SW: 9, 10, 39, 40, 44, 48, 55, 57, 
58. 

swend: 18, 58, 181. 
swside: 18, 55, 69, 119, 124, 151, 
152, 179. 

t : 8, 64, 65, 66, 68. 

TABLET: 11, 12, 70, 93, 135. 

TAKE: 13, 14, 92, 100, 112. 

tall : 18, 45, 54. 

tally. 88,89,172,178,183. 

text-. 5, 6, 8. 

thru: 18, 34, 61. 

tight: 18, 54. 

time: 2, 156. 

tite: 18, 48, 70. 

Tolkien, John Ronald Reuel: 57. 
tolower: 2, 71, 72. 
too -easy: 172 . 174. 

TOSS: 13, 14, 99, 117, 122, 126. 
toting: 63, 64, 74, 86, 88, 90, 93, 
94, 99, 100, 101, 104, 107, 110, 
111, 112, 113, 114, 117, 122, 
132, 134, 135, 139, 147, 149, 
151, 172, 174, 181, 182, 186, 


191, 

195. 



toupper : 

2, 79. 



transitive: 76, 78, 79, 

82, 

92, 93. 

travel-size: 20, 62. 



travels : 

20, 23, 62. 



TREADS: 

11, 69, 88. 



TREADS.: 

n, 69. 



TRIDENT: 

11, 12, 70, 134. 


troll: 18, 55, 57, 62, 146. 


TROLL: 

U, 12, 55, 57, 

69, 

98, 117. 

119, 

122, 124, 125, 

126, 129, 

139, 

151, 152, 179. 



TROLL. : 

U, 69, 119, 124, 

152, 

179. 




TR0LL2: 

11, 69, 119, 124, 

151, 

152, 

179. 




TR0LL2_ : U, 69, 119, 124, 152, 
179. 

true: 2, 66, 71, 95, 160, 180, 181, 
184. 

try-motion: 78, 91. 
try-move: 75, 76, 78, 86. 
tt: 66, 88 . 
turns: 76, 77, 198. 
twist: 39 . 

twist-hint: 20, 36, 56, 194. 

U: 9, 10, 23, 26, 30, 31, 32, 35, 36, 
38, 39, 40, 41, 42, 43, 44, 45, 
46, 50, 52, 55, 56, 57. 

■upnout: 18, 61. 

UPSTREAM: 9, 10, 26, 28, 29, 42. 
VALLEY: 9, 10, 27. 
valley: 18, 23, 26, 27, 28, 91. 
VASE: 11, 12, 70, 101, 110, 111, 
117, 121. 


verb: 

76, 77, 

78, 79, 82 

132, 134, 

148. 

view: 

18, 57, 

70. 

VIEW: 

9, 10, 

57. 

visits: 

20, 86 

i, 88, 141. 

W: 9, 

10, 23, 

25, 26, 27, 


31, 32, 34, 35, 36, 37, 38, 39, 
40, 41, 42, 44, 45, 46, 47, 49, 
50, 51, 53, 54, 56, 57. 
w: 6, 8. 

WAKE: 13, 14, 101. 

WALL: 9, 10, 41. 
warm: 18, 57. 
warned: 184, 185 . 
was-dark: 84, 85, 86, 102, 141. 
WATER: 11, 12, 70, 90, 100, 104, 
106, 107, 108, 109, 110, 112, 
115, 191. 

water-here: 74, 83, 90, 100, 106. 
Watson, Richard Allan: 45. 
WAVE: 13, 14, 99, 139, 148. 
west: 18, 40, 70. 
west-count: 80, 81. 
wet: 18, 42. 

wfiss: 18, 34, 35, 61, 69, 70, 99, 
159. 

wide: 18, 53, 54. 
windoe: 18, 41, 49, 69. 
window: _L8, 48, 49, 69. 


392 Selected Papers on Fun and Games 

wordl : 72, 73, 76, 78, 79, 80, 83, 

97, 105, 128, 136. 
word2: 72, 73, 76, 78, 79, 82, 83, 
97, 105. 

wpit : 18, 46, 47, 61, 70. 

w2pit: 18, 46, 52, 61, 69. 

XYZZY: 9, 10, 25, 31, 97, 148. 

y : 71- 

yes: 71, 95, 189, 194. 
y2: 18, 25, 41, 51, 157, 159, 178. 

Y2: 9, 10, 32, 41. 


( Additional local registers 22 , 68, 144 ) Used in section 2. 

(Advance dflag to 2 162 ) Used in section 161. 

( Apologize for inability to backtrack 145 ) Used in section 143. 

(Block the troll bridge and stay put 152 ) Used in section 151. 

( Build the object tables 69, 70 ) Used in section 200. 

( Build the travel table 23 , 24, 25 , 26, 27 , 28, 29 , 30 , 31 , 32 , 33 , 34 , 35 , 36, 37 , 38, 

39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 
62 ) Used in section 200. 

( Build the vocabulary 10 , 12 , 14 , ie ) Used in section 200 . 

( Chase the troll away 119 ) Used in section 117. 

(Check for interference with the proposed move to newloc 153 ) Used 
in section 75. 

( Check if a hint applies, and give it if requested 195 ) Used in section 76. 
( Check special cases for dropping a liquid 115 ) Used in section 11 7. 

( Check special cases for dropping the bird 120 ) Used in section 117. 

( Check special cases for dropping the vase 121 ) Used in section 117. 

( Check special cases foi taking a bird 114^ Used in section 112. 

(Check special cases for taking a liquid 113^ Used in section 112. 

( Check the clocks and the lamp 178 ) Used in section 76. 

( Check the lamp 184 ) Used in section 178. 

( Choose newloc via plover-alcove passage 149 ) Used in section 146. 

( Close the cave 181 ) Used in section 178. 

( Cross troll bridge if possible 151 ) Used in section 146. 

(Deal with death and resurrection 188 , 189, 191 , 192 ) Used in section 2. 

( Describe the objects at this location 88 ) Used in section 86. 

(Determine the next location, newloc 146) Cited in section 19. Used in 
section 75. 

(Dispatch the poor bird 127 ) Used in section 125. 

( Drop the emerald during plover transportation 150 ) Used in section 146. 


witt: 18, 44, 197. 
witthint: 20, 44, 194. 
wlong: 18, 38, 39, 40. 
wmist: 18, 34, 35, 36, 38, 61. 
woods: 18, 27. 

WOODS: 9, 10, 23, 24, 26, 27, 28, 
29. 

Woods, Donald Roy: 1, 10, 49, 
52, 55, 196. 

word-type: 5, 6, 8, 78, 97. 
wordtype: 5, 7, 77. 


202. Names of the sections. 


NAMES OF THE SECTIONS 


Adventure 393 


( Extinguish the lamp 187 ) Used in section 184. 

( Fun stuff for dragon 128 ) Used in section 125. 

(Get user input; goto try-move if motion is requested 76) Used in 
section 75. 

( Give advice about going WEST 80 ) Used in section 76. 

( Give optional plugh hint 157 ) Used in section 86. 

(Global variables 7, 15, 17, 20, 21, 63, 73, 74, 77, si, 84, 87, 89, 96, 103, 137, 142, 

155, 159, 165, 168, 171, 177, 185, 190, 193, 196, 199 ) Used in section 2. 

( Handle additional special cases of input 83, 105 ) Used in section 76. 

( Handle cases of intransitive verbs and continue 92, 93, 94, 95, 136 ) Used 
in section 79. 

(Handle cases of transitive verbs and continue 97, 98, 99, too, 101 , 102 , 

106, 107, 110, 112, 117, 122, 125, 129, 130, 135 ) Used in section 79. 

( Handle special cases of input 82, 138 ) Used in section 76. 

( Handle special motion words 140 ) Used in section 75. 

( If the condition of instruction q isn’t satisfied, advance q 147 ) Used in 
section 146. 

( If GRATE is actually a motion word, move to it 91 ) Used in section 90. 

( Initialize all tables 200 ) Used in section 2. 

( Initialize the random number generator 156 ) Used in section 200. 

( Let the pirate be spotted 175 ) Used in section 172. 

( Look at wordl and exit to the right place if it completes a com- 
mand 78 ) Used in section 76. 

( Macros for subroutine prototypes 3 ) Used in section 2. 

(Make a table of all potential exits, ploc[ 0] through ploc[i — 1] 166 ) 
Used in section 164. 

( Make dwarf j follow 167 ) Used in section 164. 

(Make special adjustments before looking at new input 85, 158, 169, 182 ) 
Used in section 76. 

( Make sure obj is meaningful at the current location 90 ) Used in sec- 
tion 78. 

( Make the pirate track you 172 ) Used in section 167. 

( Make the threatening dwarves attack 170 ) Used in section 164. 

(Move dwarves and the pirate 164 ) Used in section 161. 

( Open chain 133 ) Used in section 132. 

(Open/close chain 132 ) Used in section 131. 

(Open/close clam/oyster 134 ) Used in section 130. 

( Open/close grate/chain 131 ) Used in section 130. 

( Panic at closing time 180 ) Used in sections 131 and 153. 

( Perform an action in the current place 79 ) Used in section 75. 

( Possibly move dwarves and the pirate 161 ) Used in section 75. 


394 Selected Papers on Fun and Games 

( Pour water or oil on the door 109 ) Used in section 107. 

( Print the score and say adieu 198 ) Used in section 2. 

( Proceed foobarically 139 ) Used in section 136. 

(Put coins in the vending machine ns) Used in section 117 . 

( Repeat the long description and continue 141 } Used in section 140. 

( Replace the batteries 186 ) Used in section 184. 

( Report on inapplicable motion and continue 148 ) Used in section 146. 
( Report the current state 86 ) Used in section 75. 

( See if there s a unique object to attack 126 ) Used in section 125. 

( Simulate an adventure, going to quit when finished 75 ) Used in sec- 
tion 2. 

( Snarf a treasure for the troll 124 ) Used in section 122. 

( Snatch all treasures that are snatchable here 174 ) Used in section 173. 
(Stay in loc if a dwarf is blocking the way to newloc 176 ) Used in 
section 153. 

( Subroutines 6, 8, 64, 65, 66, 71, 72, 154, 160 , 194, 197 ) Used in section 2. 
(Take booty and hide it in the chest 173 ) Used in section 172. 

( Throw the axe at a dwarf 163 ) Used in section 122. 

( Throw the axe at the bear 123 ) Used in section 122. 

( Try to fill the vase 111 ) Used in section 110. 

( Try to go back 143 ) Used in section 140. 

( Try to water the plant 108 ) Used in section 107 . 

( Type definitions 5, 9, ll, 13, 18 , 19 ) Used in section 2. 

(Warn that the cave is closing 179) Used in section 178 . 

( Zap the lamp if the remaining treasures are too elusive 183 ) Used in 
section 88. 


203. Addendum. A definitive discussion of the origins of this fas- 
cinating program has been compiled by Dennis G. Jerz, “Somewhere 
nearby is Colossal Cave: Examining Will Crowther’s original ‘Adven- 
ture’ in code and in Kentucky,” Digital Humanities Quarterly 1,2 (Sum- 
mer 2007), available online. 


Chapter 28 


Ziegler’s Giant Bar 


[This material was assembled from documents in my family archives.] 

George Ziegler (1830-1904) helped to found a candy-making company 
in 1861. Eventually the George Ziegler Company — based in Milwaukee, 
Wisconsin, where I was born - became one of the top five manufacturers 
of chocolate candy in the USA. Their most famous creation was the 
Giant Bar, introduced in 1911, the first candy bar to be sold in a covered 
wrapper. It contained “sweet buttermilk chocolate” and “number one 
roasted peanuts,” and when I was a child you could buy this delicious 
confection for just a nickel. 


FIGURE 1. Candy wrappers 
like this, once commonplace, 
are now collectors’ items. 



The Ziegler Company sponsored a weekly television program for 
children called the Museum Explorer’s Club, produced by the Milwaukee 
Public Museum and broadcast every Tuesday afternoon by WTMJ-TV. 
In 1951, when I was a student in eighth grade, they introduced a contest 
that captivated my attention: How many words can be spelled using only 
the letters of the phrase Ziegler ’ s Giant Bar? (The precise rules are 
given in Fig. 2 on the next page.) 

Immediately I could write down lots of words like learn, strange, 
beggar, zebras, etc., etc., including even longer words like librarian 
and libertarian. I was definitely hooked on the problem. 

So and I’m embarrassed to admit it, but I might as well ’fess up — 

I told my parents that I had a stomach ache and would have to stay home 
from school one day. And also another day, and another, continuing for 
two weeks as I worked on the giant-bar challenge. 


395 


396 Selected Papers on Fun and Games 


Official Rules for the Word Building Contest 

1. Using the slogan Ziegler’s Giant Bar, make a list of all the words of 
two letters or more that you can find. No proper names. You may use 
each letter in any word as often as it appears in the slogan. 

2. Print your name, address, and age plainly on your entry, and be sure to 
enclose a Giant Bar wrapper. 

3. The contest is open to all children between the ages of 8 and 15, except 
to families of persons employed by the Ziegler Candy Company and their 
advertising agency. 

4. All entries should be mailed to Giant Bar, c/o WTMJ-TV, Milwaukee 1. 
Wisconsin. 

5. Contest closes at midnight December 11, 1951. 

6. All entries become the property of the Ziegler Candy Company. Prize- 
winners will receive their prizes on the Museum Explorer’s Club program, 
December 18, 1951, at 4:15pm on WTMJ-TV. 

7. Entries will be judged on the basis of the largest correct number of words 
submitted and on neatness, accuracy, and readability. 

Figure 2. A competition that I couldn’t resist. 

My father had acquired a huge unabridged dictionary, the Funk 
& Wagnalls New Standard Dictionary of the English Language (1913), 
which I had been wanting to examine more closely. It contained 2757 
large-format pages packed with small type - nearly 16,000 characters 
per page. But I realized that I wouldn’t have to look at the whole thing. 
For example, I could completely skip past all words that began with c. d, 
f , h, j , k, m, o q, and u -y; thus at most 1497 of the 2757 pages would 
be relevant. Furthermore, the same culling process could be applied to 
the second letters of words: I could jump from ac- on page 1*6 to ae on 
page 43, and from af- on page 46 to ag on page 50, etc. The third and 
subsequent letters of words also allowed similar speedups. 

So I made myself a little card that contained the whole repertoire 
of available letters, in alphabetical order: 

aabeeggiilnrrstz 

By running this card along the columns of definitions, I could rather 
quickly identify all of the permissible words. (In retrospect, it seems 
that algorithmic thinking” was already in my blood at the time.) 

Lots of scratch-paper was available in our house, so I wrote down 
each giant-bar word as I found it, filling many sheets. My parents soon 
noticed what I was doing, of course, and this must have presented them 


Ziegler’s Giant Bar 397 

with quite a dilemma. Should they punish me for playing hooky? (I did 
actually have some digestive problems, not entirely imaginary, but I also 
was feeling “consumed” by this project.) Fortunately, by the second 
week, they had gotten into the spirit of the hunt, and they even helped 
me to type up the results of my labors. 

When the work was complete, I had come up with a total of 4,766 
words, broken down by first letter as follows: 


a . . 

. 667 

g-- 

. 718 

n . . 

. 148 

t . . 

. 470 

b. . 

. 862 

i . . 

. 165 

r . . 

. 553 

z . . 

. 59 

e . . 

. 248 

1 . . 

. 375 

s . . 

. 501 




(Actually I thought I had identified 4,768 valid words; but I see now that 
my list included two instances of two- word combinations, ‘ab intra’ and 
‘in re’, which violate the rules. Those two have been deleted from the 
counts above.) I submitted the list on 21 typewritten pages of legal-size 
paper, with four columns of roughly 55 words per page. 

Here, for example, were the first words that I found, preceding ‘ae’: 


aa 

abatis 

aberre 

ablegating 

abregers 

aal 

abe 

aberrs 

abler 

abrest 

aalii 

abear 

abet 

ablest 

abri 

aaliis 

abearing 

abets 

ablet 

abrin 

aals 

abears 

abgregate 

abligate 

abris 

aar 

abee 

abgregates 

abligates 

abs 

aas 

abegge 

abietin 

ablins 

absent 

aba 

abegges 

abigeat 

abnegate 

absenter 

abaiser 

abeile 

abigeats 

abnegates 

absit 

abanet 

abel 

abit 

abnet 

abstain 

abanets 

abele 

abite 

abnets 

abstainer 

abas 

abeles 

abites 

abra 

absterge 

abase 

aberr 

ablate 

abras 

absterging 

abaser 

aberrant 

ablates 

abrase 

abstringe 

abasing 

aberrate 

ablaze 

abras ing 

abstringer 

abate 

aberrates 

able 

abrasite 


abater 

aberrating 

ablegate 

abreast 


abating 

aberratings 

ablegates 

abreger 



(The one- letter word a was, of course, disallowed by rule 1.) Notice 
that nouns, like aa, aal, aalii, aba, etc., can usually be made plural 
by adding an s. Verbs, like abase, usually take the suffixes -er, -ing, 
and -s; adjectives, like able, often take -er and -est. I saved time 


398 Selected Papers on Fun and Games 

by noting such things down in abbreviated form, eventually supplying 
the full words only when everything was typed up. It was necessary to 
avoid using a letter too often; for instance, abase leads to abaser and 
abasing but not to abases, because only one s is available. Later on 
in the alphabet, I could go from rare to rarest but not to rarer. 

How well did I do? Can I improve on this list today, as an adult? 
While writing this chapter I decided to experiment with Stuart Flexner’s 
Random House Dictionary of the English Language , second edition, 
unabridged (1987), which sits next to the chair where I do most of my 
work. Trying to put myself back into the shoes of an eighth-grader, I 
came up with only 38 words, compared to the 87 listed above! Okay, 
I wasn’t good at plurals when getting started this time — I missed aas, 
aaliis, abas, and abris -so I should have had 42 instead of 38. Still 
there was quite a lot of difference: The Funk & Wagnalls collection that 
I’d used in 1951 included 54 words that are absent from Flexner’s list. 

I knew that different unabridged dictionaries choose to mention dif- 
ferent words, but I was surprised by how different they actually are. So 
I looked closer, and found that 12 of the 54 “extra” Funk & Wagnalls 
words are not in the Oxford English Dictionary either. (For example, 
the vintage-2010 OED lacks abigeat, abit, ablins, absterge.) All 12 
of the mystery words were, however, present in the current online Wik- 
tionary, with three exceptions: Funk included abreger and abregers as 
verbs, borrowed from French by musicians who shorten a composition; 
and he included abrest as a simplified spelling of abreast, credited to 
the Simplified Spelling Board.* 


The Simplified Spelling Board, a group of several dozen leading lexicog- 
raphers organized in 1906 with the backing of Andrew Carnegie and U.S. 
President Theodore Roosevelt, desired “to promote, by systematic and con- 
tinued effort, the gradual simplification and regulation of English spelling.” 
Many of their suggestions- like ‘ether’ for ‘aether’, ‘license’ for ‘licence’, 
omelet for omelette , draft’ for 'draught 1 , ‘plow’ for ‘plough’, ‘criticize’ for 
‘criticise’, ‘sulfur’ for ‘sulphur’, ‘fiber’ for ‘fibre’ - have been widely adopted, 
at least in America. But most of them- including ‘hed’ for ‘head’, ‘hart’ 
for ‘heart’, ‘dout’ for ‘doubt’, ‘dum’ for ‘dumb’, ‘aile’ for ‘aisle’, ‘fild’ for 
‘filled’, ‘justis’ for ‘justice’, ‘adjectiv’ for ‘adjective’, ‘infinit’ for ‘infinite’, 
‘surprize’)!) for ‘surprise’ — have found little acceptance. 

Funk s dictionary also listed simplifications that were proposed at the 
time by the American Philological Association, who went further: The word 
little wasn t litl enough for them! I had only a few opportunities to include 
APA spellings for giant-bar words; I could have listed gagl, gigl, and nigl. 
But I either missed them or decided that they were too far out. 


Ziegler’s Giant Bar 399 

Conversely, Random House came up with several entries before ae 
that F&W didn’t: abelia, abelias, abient, ablare, abristle, 
abseil. My new list also included three that I had mistakenly over- 
looked in 1951: abigail, ablating, abuser. (The first of these was 
hidden under the proper name Abigail; an alternate usage of that word, 
meaning “maid,” was cryptically said to be spelled ‘[a-]’.) Adding these, 
together with the word abates (which I had somehow failed to include 
in 1951 as well as in 2010) and the word abelian (which mathemati- 
cians now commonly write with lowercase a), makes a grand total of 
87 + 9+1 + 1 = 98 words before ae that all have a legitimate claim to 
be giant-bar eligible.* 

You may have noted that the phrase “Ziegler’s Giant Bar” in- 
cludes an apostrophe. I saw that too, and my list of 4,766 submitted 
words included 11 cases where I’d found an apostrophe as part of a 
dictionary entry: ain’t, an’t, aren’t, e’en, e’er, ’gainst, isn’t, 
it’s, ta’en, ’st, ’tis. Near the end of the project I realized that 
apostrophes could also be used much more often, to form possessive 
forms of nouns. For example, from aa I could make both aa’s and 
aas ’ , meaning something that belongs to a Hawaiian lava flow or to 
more than one lava flow. I left such cases out, because there wasn’t 
time to make a supplementary list and because I feared that I would be 
stretching rule 1 too far. If apostrophes were really OK, I could also 
have included plural forms for each of the relevant letters: a’s, b’s, 
e’s, g’s, i’s, l’s, n’s, r’s, t’s, z’s. 

For the record, my list contained just three words of twelve let- 
ters or more: arterializes, interregalia, and the grand champion, 
interregalias. The final entries of my list, alphabetically speaking, 
were ziraleet, ziraleets, zita, and zitas; nowadays Random House 
would allow me to follow those by ziti and zits. 


At last the big day came, 18 December 1951. Surprise: I’d won! 



FIGURE 3. My debut on (low-definition) television, vintage 1951. 


* Well, perhaps abrest should be disallowed. 



400 Selected Papers on Fun and Games 

I met the judges, who had had only one week to read through all of 
the contest entries, and learned that fewer than 2,500 words had actually 
been on their “master list.” 

The big prize, a television set with a 17-inch screen, was given to 
my school at a formal ceremony on 21 December. It was installed at the 
front of the eighth-grade classroom; my teacher used to come to school 
on Friday nights to watch boxing. I received a handsome red toboggan, 
about ten feet long, that was destined to provide much pleasure during 
Wisconsin winters. And plenty of candy bars were also given out to the 
other members of my class. 

The Emmaus Lutheran Sunday Bulletin for 23 December said, “We 
are happy over Donny’s efforts and will tell more in the January Visitor.” 
But no copies of that publication seem to have survived. 

According to Donn Brazier in The Explorer’s Log #81 (Milwaukee 
Public Museum, 1 January 1952), “The Giant Bar contest is over, and 
Don Knuth, 13, with over 4000 words, won the TV set for his school 
Emmaus Lutheran, 8th Grade. How does the toboggan perform these 
snowy days, Don?” Twenty-nine other students were awarded subsidiary 
prizes; the second-place winner, Billy Betlike, reportedly found about 
2000 words. 

Afterthoughts 

I am indebted to Susan Otto of the Milwaukee Public Museum Reference 
Library for details about the official contest rules. 

The WTMJ-TV show Museum Explorer’s Club was probably among 
the first of its kind. It began in 1948 as a “sustaining program,” namely 
a program that the station presented as a public service, without com- 
mercial sponsorship or advertising support [see The Billboard 62,42 
(16 October 1948), 14]. In 1951 the Ziegler Company was a sponsor; 
they switched to one-minute commercials in 1952. Tve been unable to 
identify the handsome host who appears in Figure 3; it wasn’t Murl 
Deusing, who also appeared on the program, nor was it Donn Brazier. 

When reading that issue of The Billboard I couldn’t help but notice 
that they routinely used the term “tele” for “television” in those days. 
There were tele stations” and “tele surveys,” etc. It’s strange that this 
attractive coinage never entered the popular vocabulary. (If so, I could 
have used tele in the contest.) 

Readers of Chapter 32 will be pleased to know that I did know the 
word baas when I was young. It appeared on the third page of my list, 
together with baaing. 


Chapter 29 


Th 5 E 4 CH 3 EmIC 2 Al 2 Ca 3 P 4 Er 

[Originally published in Engineering and Science Review , Case Institute 
of Technology, 2.3 (March 1959), 32.] 

No doubt countless chemists have contemplated whether their formulas 
can be put together to make English sentences. A little trial will show 
that very few words can be written as chemical compounds (for example, 
the words “little” and “trial” cannot). The following story, however, is 
written entirely in terms of meaningful chemical combinations, though 
we must admit that some of them are highly unstable. Notice the use of 
the new elements emanation Em (86), einsteinium E (99), and mende- 
levium Mv (101), and of the “inert gas trap” pictured on the next page. 

TI15E4 CH 3 EmIC 2 Al 2 Ca 3 P 4 Er 

ON 2 Ce 2 U 2 Po 3 N 2 A SH 3 INY AF 3 Te 2 Rn0 2 0N I 3 N 7 
Se 4 PtEmBEr, S 3 Ir 2 P 7 ErC 3 Y 3 H 6 AgErTi, Th 5 E 4 P 2 H 3 YSiCS 4 
WHI 2 P, WHoSe 3 Mg Ra 3 N 2 0 6 UTa 2 Ga 2 S 3 In Fr 6 0 4 NTa 
CYN 2 ThIAS HoUSe 3 , WA1KS 4 In S0 2 He Ca 3 N 2 USe 3 H 3 Er 
P 3 Ho 3 Ne. He CA1 2 S 3 UP IV 5 AN 3 VON DyCK, AN 2 OThEr 
ScI 3 EN 2 Ce F 5 IENd, ANd 0 3 F 6 F 2 ErS 2 Ta 2 SH 2 0 2 W Th 5 E 4 
GeNTl 2 EmAN 2 H 3 IS Pr 2 OOF 4 ThAt 4 Mv 4 = Mv 2 . 

IV 5 AN 3 , HoWEV 2 Er, HAtE 2 S 3 P 7 ErC 3 Y 3 BeCAu 2 Se 4 ThE 2 Y 2 
B 2 0 5 Th H 4 AVE A CrUS 4 H 2 ON CYN 2 ThI 2 A. IV 5 AN 3 , WI 6 Th 
A SmIrK 4 , SAY 2 S 2 He I 2 S 7 VErY H 3 APPY ThAt 4 He H 3 As 
ThloS CH 2 AN 3 Ce. He Ru 4 N 2 S In H 5 AsTe ANd APPr 2 0 2 AcHeS 
H 3 Er HoUSe 3 . 

He H 3 As A KNiFe, BeCaUSe 4 He I 2 S A RaScAl. WHEN 2 
He ReACHeS 4 H 3 Er HoUSe 3 , He S 2 TaBS 2 CYNThIAs 2 MoThEr 2 , 


401 


402 Selected Papers on Fun and Games 

ANa 2 S 7 TaSiA, ANd ThReAt 3 ENS 2 P 7 ErC 3 Y 3 A1 2 (S0 4 ) 3 . 
HoWEV 2 Er, P 7 ErC 3 Y 3 , Th 5 E 4 HEr0 2 , ANTi 2 CI 2 PAtES ThI 2 S 
MoVE, As He H 3 As TaKEN 3 CaRe 7 Ta P 3 Ho 3 Ne Th 5 E 4 Po 3 Li 3 Ce. 
ThsE 4 Co 4 P 2 S CaTcHs IV 5 AN 3 ANd TaK 2 E 3 Tli 5 E 4 Sc 2 Al 2 AWAg 
AW 5 AY 3 . “Y0 3 U S 3 URe WErE LuC 2 K 2 Y,” SAY 2 S 2 CI 10 NdY, 
ANd SHe ANd P 7 ErC 3 Y 3 LiVE HAPPILi 6 WI 6 Th EACH 3 O s ThEr 2 
F 7 0 2 ReVEr. 


Th 5 E 4 E 3 Nd5 


- K 2 N 3 UTh 



Emanation gas (Em) is normally 
inert, but in the CH 3 EmIC2Al 2 
compound shown it is held in 
the molecule by the surrounding 
carbon and aluminum atoms. 
Argon and helium are combined 
in similar ways in the story. 


Addendum 

Every student at Case Institute of Technology had a knowledge of basic 
physics and inorganic chemistry. Indeed, almost every classroom dis- 
played a large chart of the periodic table, which listed all of the various 
atomic elements currently known. 

To fully understand this story, however, you need to know that our 
charts in those days used ‘A’ as the symbol for argon, not ‘Ar’. We also 
knew the recently discovered elements 99 and 101, called einsteinium and 
mendelevium, by the symbols ‘E’ and ‘Mv’; those symbols had been sug- 
gested in 1955 by the team that had discovered them, led by A. Ghiorso. 

Element 86 has historically been known by different names, because 
it is radioactive. In general it was called emanation gas (Em) when I 
learned about it in the 1950s. But it had long been known to have three 
main isotopes that occur in nature as “emanations” from other radio- 
active elements, namely radon (from radium), thoron (from thorium), 
and actinon (from actinium). Radon is the most stable of these isotopes, 
having a half-life of 3.8 days; furthermore, radon actually arises more 
often in nature from the decay of uranium than from the decay of radium. 
Thus radon was by far the most important isotope, and element 86 was 
most commonly called radon ; its symbol ‘Rn became standard in 
1925. The alternative symbol ‘Em’ was still, however, in common use 
until the 1960s. Notice that my story uses ‘Rn’ once and ‘Em’ thrice. 


Th 5 E4 CH3EmIC2Al2 CaaPjEr 403 


The Commission on Atomic Weights of the International Union of 
Pure and Applied Chemistry meets every few years to adopt new stan- 
dard conventions. In 1957 they upset my applecart, by changing the 
symbols for argon, einsteinium, and mendelevium to ‘Ar’, ‘Es’, and ‘Md’, 
respectively. Fortunately I didn’t know about it at the time these de- 
cisions by the higher-ups take awhile to trickle down to undergraduate 
students — because their new rules basically doomed my project from 
the start: Without ‘A’ and ‘E’, I couldn’t form crucial words such as 
‘a’ and ‘the’. (Were the scientists on the international committee pur- 
posely trying to make literary chemistry impossible?) Furthermore, the 
change to ‘Md’ threw out my joke about the conservation of momentum 
(Mv! = MV 2 ). Thank goodness I was able to write my little tale before 
the task that I had undertaken became hopeless. 

My proposal for an “inert gas trap” was, of course, not serious when I 
made it in 1959. But I learned recently that radon can actually be caged 
inside a fullerene! 

How many words can actually be formed as concatenations of the 
chemical element codes? Most words, including ‘little’ and ‘trial’, remain 
impossible, even if we go up to the newly discovered-and-named elements 
through number 112 (Cn for copernicium). A nice way to formulate this 
problem mathematically is to consider the power series W = 1/(1 — A) 
in 26 noncommutative variables {a, &,..., 2 }, where A is the sum of all 
element codes. The value of A that I used for the chemical caper was 

Ao = h+he+li+be+b+c+n+o+ f +ne+na+mg+al+si+p+s-\-cl+a 
+k+ca+sc+ti+v-\-cr+mn+fe+co+ni+cu+zn+ga+ge+as 
+se+br+kr+rb+sr+y+zr+nb+mo+tc+ru+rh+pd+ag+cd 
+in+sn+sb+te+i+xe+cs+ba+la+ce+pr+nd+pm+sm+eu 
+gd+tb+dy+ho+er+tm+yb+lu+hf +ta+w+re+os+ir+pt 
+au+hg+tl+pb+bi+po+at+em+rn+ fr+ra+ac+th+pa+u 
+ np + pu + am + cm + bk + cf + e + fm + mv\ 

nowadays we would have to use 

A = Ao — a 4- ar — em — e + es — mv + md 

+ no + Ir + rf + db + sg + bh + hs + mt + ds + rg + cn. 

The corresponding power series include the terms 

Wo = l + a + &-|-c-|-e + -- --|- the + the + thf + • ■ • + 2 caper + • • • ; 

W = l + b + c+ f + -- - + the + thf + • • • + caper + • • • . 


404 Selected Papers on Fun and Games 

It turns out that W 0 contains exactly 1928996 of the 26 5 = 11881376 
possible five-letter words, ranging from aaa.aa to zrzry (about 16%). 
But W contains only 1497203, ranging from acacb to zrzry (about 13%). 
If we restrict consideration to the 5757 five-letter words of English, as 
defined by the Stanford GraphBase, W 0 has 2120 of them, while W has 
1689. Thus, whenever I thought of a five-letter word, I had about a 37% 
chance of being able to actually use it in the story. 

The five-letter word basin has coefficient 8 in Wq ; this means that 
there are eight ways to make a basin chemically, e.g., B 2 AS 2 IN or • • • 
or BaSiN 2 . In this respect basin is unique, because all other English 
words of five or fewer letters have coefficients of 7 or less. On the other 
hand, when we consider today’s revised chemical codes we find that no 
English five-letter word in W has a coefficient greater than 6, which is 
the coefficient of cocos and cohos. (Nonwords like bhosb and 284 others 
do have a coefficient of 8 in W.) 

Incidentally, I still remember being absolutely delighted to discover 
that aluminum sulfate is also a word. 


Chapter 30 


N-Ciphered Texts 


[Originally published in Word Ways 20 (1987), 173 174, 191 192.] 

Some years ago, while doing research on typography [1], I made a special 
font of type that obscured the letters in order to study the effects of 
spacing. Some of my students happened to look at one of my examples, 
and decided on their own initiative to figure out the words that I thought 
had been obliterated. To my great surprise, they were not only able 
to reconstruct a highly complicated and abstruse text, but they also 
enjoyed every minute of the task! They were so hooked on the problem 
that they spent the whole night puzzling it out, and the next morning 
they challenged their friends to do it. 

Believing that others might enjoy scratching their heads over this 
new type of “many to one” cryptogram, I have generated several simple 
texts that seem especially suited to this kind of game. Here are the 
alphabets I used, so that you can determine how the letters from A to Z 
look in capitals and lowercase: 

NNNNNNNNIINNNNNNNNNNNNNNNN 

nnnnninmininnnnnniinnnnnn 

The concealed texts include some quotations by famous statesmen, 
a few limericks, and a surprise or two. Two pages of hidden quotes are 
followed by two pages of answers; don’t peek! 

Hint: The first word of the first quote is ‘To’. 

Reference 

[1] Donald E. Knuth and Michael F. Plass, “Breaking paragraphs 
into lines,” Software Practice & Experience 11 (1981), 1176. 
Reprinted and extended in Donald E. Knuth, Digital Typography, 
CSLI Lecture Notes 78 (Stanford, California: Center for the Study 
of Language and Information, 1999), 140-141. 


405 


406 Selected Papers on Fun and Games 


!• Nn mniinnin nn nnini I nnn mnnnrinnn 
nnnnn n mnmnn ni n nnnnnnnn, nnn nnnininnn 
m Nmnn nun inn nmn ni mu nimnnn nnn 11 
nnn nnn minniinn m nnnnn inn mu nnnn ni 
inn nnnnnnnn ni nn nunnnnn nm nnnn innni. 
Nnn Nmnn, nnnin ininnnii nnn nnn ni ninn 
nnnn, min: “Nnn Nnn nnnnnnn inn nnnnmnn- 
lnn *” — NTinunn N. Nnnnnnni 

2. Ninn nn ninnn nnn, inn Nninnnn ni Nnnnn- 
unn nnn Nnninnn n nnn nmnn nnn nmn nn nn- 
nmnnn nn mnn nnn nnunni nnnn, nnn in inn innn 
nnnnnn in nnnn nnn nnnini in nnnin inn mnn- 
nm nnninin nnninnnnn in n. -Nnnninnn Nmnni 

3. I mnn nmnnnnnnnn, in mu lnmnnnn, nnnn 

n mm ni mmnii. I nnnn nnn nnnn in inn nnn- 
ninnnn nnnnn nnnin in ininn ni nnnnnmn, nnn 
inn mu nnninn — I nnn nnnnn nn nnninnn nun 
nnn nnn nnn nnnin nn ninnnnnnn nnnnnn in 
nnnn nn. -Nninnnn Ninnnin 

4. Nmn nn nnn ni nn innnn nn nn inn 
Nn nn nnnnnnn, nmn innnin nnn nmn, 

“Nnnm nnnn nnnnnmn, nn nnnnn, 

In n nnnmn ni nnnm, 

Nnn nnninn n nnninimn ni Nmn!” 

5. Nmn n nmnnnnn nnnm nnnnn Ninmn, 

“Nn inn mnn nnn nmnn mm nnnnnmn, 

Nnn nmn ni nnn nnn 
Nnnmn Nnn., Nnn., nnn Nnn., 

Nnnn in Nnn. innn nnm in nnn mnnin!” 


N-Cipliered Texts 407 


6. N rrnn mnnn nn Nnnn Nrrun nnn Nn. 

Nnnn mnmn nnniniinn mm nn’n mn. 

Ni inn rrnn inni nn inn 
Nnrrnmn nmi nnnn nn nnnn. 

Nnn nnnnni, innnnmnn, nmn’i nn. 

7. Nnnnn nm n nnnnn mil in Nnnnn 
Nnnnn nrrnninnn nnnnn nnnin innn. 

Nnnn innnnnn mnnn nnn, 

Nnn min nun n nnn, 

“Ii’i nnnnnin I ninnni nunrrni in nm 
nn nnnn nnnnn min inn inn nnn 
ni I nnnninm nnn.” —Nnnnn Nnnnnnn 

8. Ii rrnn nn nnnnnnnn in inn mninnrrnuninnn 
inni innn n ininn inn. Nm inn n nm ininn 
nnn; inn n inn innninnn nrrnn nnn. Nnni n 
nnn, in nnnn ni n nnnnnnn nnnnnnninnnn, inn 
nnnin nm ninnni nninnn nn nnnnnnnn. 

— N. N. Nnnninninn 

9. Ii mnnn nnnn nn nnnnini in ininn, innnn 
nnnin nn nn nnnmnni in nm; nnn n innnn nnnn 
nn nnnmnnn in nn mnnn, nnni n nnnin in nnnin 
nn! Nn mnmn nil nn nnnnnn nnnnnmni, nnn 
nnnnnnnniinn nnnin nn nnninnn nnn min. 

— Nnnnn N. Nnnnnnn 

10. Nnnn: 1. Nnnnnnnni, inn, nnnni. 2. N 

ninnnmnn ni inn nninnn ni n nnninni, ninnnn nn- 
nnnninn in mini, nnn nnninnn nn innnninn mm, 
nnnnnin, nn nnnn mninnn. 3. Nnn nninnn nn 
mnnn mnn nn nnn nnninnn, nnnnni nn nmnn in 
inn nnnin. —Nninnn Nnmnnmi Ninnnnnnn 


408 Selected Papers on Fun and Games 


1. To illustrate my point I had meanwhile 

drawn a picture of a crocodile, and explained 
to Stalin with the help of this picture how it 
was our intention to attack the soft belly of 
the crocodile as we attacked his hard snout. 
And Stalin, whose interest was now at high 
pitch, said: “May God prosper this undertak- 
ing.” -Winston S. Churchill 

2. Like all other arts, the Science of Deduc- 
tion and Analysis is one which can only be ac- 
quired by long and patient study, nor is life long 
enough to allow any mortal to attain the high- 
est possible perfection in it. -Sherlock Holmes 

3. I most emphatically, in this instance, made 

a fool of myself. I have now come to the con- 
clusion never again to think of marrying, and 
for this reason — I can never be satisfied with 
any one who would be blockhead enough to 
have me. -Abraham Lincoln 

4. Said an ape as he swung by his tail 
To his children, both female and male, 

“From your offspring, my dears, 

In a couple of years, 

May evolve a professor at Yale!” 

5. Said a calendar model named Gloria, 

“So the men can enjoy real euphoria, 

You pose as you are 
During Jan., Feb., and Mar., 

Then in Apr. they want to see moria!” 


N-Ciphered Texts 409 


6. A man hired by John Smith and Co. 

Once loudly declared that he’d tho. 

Of the men that he saw 
Dumping dirt near his store. 

The drivers, therefore, didn’t do. 

7. There was a young girl in Japan 
Whose limericks never would scan. 

When someone asked why, 

She said with a sigh, 

“It’s because I always attempt to get 
as many words into the last line 
as I possibly can.” —Martin Gardner 

8. It may be conceded to the mathematicians 
that four is twice two. But two is not twice 
one; two is two thousand times one. That is 
why, in spite of a hundred disadvantages, the 
world will always return to monogamy. 

— G. K. Chesterton 

9. If there were no puzzles to solve, there 
would be no questions to ask; and if there were 
no questions to be asked, what a world it would 
be! We should all be equally omniscient, and 
conversation would be useless and idle. 

— Henry E. Dudeney 

10. Game: 1. Amusement, fun, sport. 2. A 

diversion of the nature of a contest, played ac- 
cording to rules, and decided by superior skill, 
strength, or good fortune. 3. Wild animals or 
birds such as are pursued, caught or killed in 
the chase. —Oxford Universal Dictionary 


410 Selected Papers on Fun and Games 

Addendum 

Texts 7, 8, and 9 did not appear in the original Word Ways article. 

Readers who wish to do their own experiments can use METRFONT 
to make similar fonts, by visiting the webpage 

http : / /www-cs-f acuity . Stanford. edu/~knuth/programs .html 

and downloading file nnncmbx.mf. 


Chapter 31 


Disappearances 


[Originally published in The Mathematical Gardner, edited by David A. 
Klarner, a festschrift for Martin Gardner on his 65th birthday (Belmont, 
California: Wadsworth, 1981), 264.] 

N.B.: When the right-hand portions of the eight-line poem on the fol- 
lowing page are interchanged, a seven-line poem results. Which line 
disappears? 


411 


412 Selected Papers on Fun and Games 


0 

<V 


CO 

Oh 


S 

Oh 

0 

/ 


CD 

CD 

CO 

t5 


43 

CO 


O 

43 


CO 

3 


Dh 

43 

f— i 

o 

c3 

fl3 

1 

Sh 



_5h 

"o 



CD 


rO 

t-H 

'o 

43 

c3 

> 

CD 

44 

4-3 

<3 

co T) 

d 

cl 

DCj 

4-3 

§ 


0 

s 


‘So 


CD 

43 

CO 

0 

d 


4-3 

CO 

0 


0 

bjO 

> 


a 

g 

<> 

O 

CD 


X 

X 

<D 

o 

4-3 

Dh 

CD 

T3 

0 

43 

fH 

CD 

4-3 

.s 

CO 

CD 

43 

«-t — i 

4-3 

f-H 

o 

Oh 

CO 

o 

£ 

4-3 

O 

TJ 

0 

0 

«3 

l-H 

0 

0 

4-3 


0 

0 


0 

CD 

o 

a 

co 

0 

CD 

o 

43 


0) 

44 


O 

£ 

CD 

+3 

0 

X 

43 

cd 

0 

W 


0) 

43 

cd 


0 

o 

*> 

<D 

T3 


0? — ' 

^ S 
0 

"~0 
CD 

43 


0 

0 

X 

T3 

CD 

T3 

0 

CD 

a 


£ S 

o S 

43 -J3 


o 


CD 

> 

CD 

0 

0) 

X 


b€ 

g 

aj 


bO 

0 

O 

43 


o 

-+j 

«3 

4-3 

‘Sb 

'■a 


<D 

t-4 

Oh 

(D 


There must be something secret, yes, a trick that will involve 

- when done with sleight of hand — a force that’s able to dissolve. 


The prestidigitators, making use of devious schemes, involve 


Disappearances 


413 


03 

0 ) 

a 

Ph 

o3 


X) 

a 


p 


bO 

a 


o 

> 

'■p 

p 

o3 


-p 

a> 

.CO 

’3 

a3 

tT 

0 ) 

Ti 


^3 


,P 

P 


o3 

r P 


<d 

4-5 

<P 

aj 


bO 

a3 


£ 

O 

a; 

X 3 

P 

o 

£ 


a3 


<v 


+3 "O 

o a 

P a3 


£ 

O 

rP 


P 4^ 
o c 


3 £ 




a3 

rP 


"P 

a 

o3 

P 3 


<D 

> 

0 ) 

P 

CD 

rP 


rP 

bD 


O 

,P 


^ b0 
P "nl 


a; 


<D 

P 

O 

"P 


CD 


0 ) 

P 3 

H 


414 Selected Papers on Fun and Games 

Addendum 

When I composed this poem I was unaware that members of the Oulipo 
[Ouvroir de Litterature Potentielle], especially Claude Berge, had been 
performing similar magic. Their ingenious poems [1, 2] consist of 14 
lines in ordinary sonnet form, rearrangeable into 15 lines. The gen- 
eral principle is based on Sam Loyd’s paradoxical “Get Off the Earth” 
puzzle [3]. 

Although the meter and rhyming scheme of my poem are non- 
standard, I do claim that mine is more “perfect,” because it does not 
require any changes of punctuation or capitalization when the right-hand 
lines are switched. 

(See also the disappearing Christmas sheep and angels in Chap- 
ter 46.) 

[1] Claude Berge and Jacques Roubaud, “14 = 15, Sonnets a con- 
traintes Loydiennes,” Atlas de litterature potentielle (Paris: Gal- 
limard, 1981), 189-193. 

[2] Claude Berge, La Princesse azteque, ou contraintes pour un sonnet 
a longueur variable, La Bibliotheque Oulipienne, numero 22 (1983); 
republished in the collection La Bibliotheque Oulipienne (Paris: 
Ramsay, 1987), 73-82. 

[3] Samuel Loyd, “Transformation picture,” U.S. Patent 563778 (14 
July 1896). 


Chapter 32 


Lewis Carroll’s word— ward— ware— dare— dame— game 

[Originally published in GAMES 2,4 (July 1978), 22-23.] 

With the way fashions change from funk to punk, it’s easy to see the 
difference that a single letter can make. One typographical error in a 
math book might change conic sections into “comic sections.” 

Lewis Carroll, the immortal author of Alice in Wonderland, realized 
how much fun it would be to play with sequences of one-letter changes. 
So at Christmastime in 1877, he invented a game he called Doublets to 
amuse two of his young lady friends who had “nothing to do.” 

One of his first puzzles was to change grass to green. The object 
is to remove one letter from grass and substitute another in its place 
to form a new word. The same thing is done with each new word — 
substituting only one letter and leaving the positions of the others un- 
changed — until the final word is reached. Carroll’s solution went from 
grass to crass cress -tress trees frees freed -greed and thence 
to green. Curiously, he missed the fact that two of those steps could 
be replaced by the single word treed. There is another nice 8-step 
solution that goes from grass to grabs- 

creed-greed and finally to green. (Can you provide the four common 
words that I’ve left out?) 

If rare words are permitted, then four steps will do the trick, namely 
grass grays greys grees green. But that’s not a very satisfying so- 
lution unless you happen to be familiar with grees. 

So what vocabulary is appropriate for Lewis Carroll’s game? Car- 
roll defined it as those English words “such as might be used in good 
society,” a difficult standard to establish these days. I personally prefer 
solutions that stick to the words I know well, since much of the plea- 
sure in this type of puzzle comes from finding new connections between 
unlike concepts. Almost every pronounceable combination of four or 
five letters has probably been used as an archaic spelling for something 
somewhere, but that spoils the game. Therefore I usually rule out words 


415 


416 Selected Papers on Fun and Games 

that send me scurrying to an unabridged dictionary; in fact, even the full 
vocabulary of a college dictionary seems to be too much. I recommend 
solving with words that are in common use, since they should suffice in 
a well-constructed puzzle. 

The Order and Method Approach 

Doublets have been popular ever since Carroll published his first exam- 
ples in the British magazine Vanity Fair. In fact, the game is so popular 
that it now has many different names: Word Links, Word Ladders, Word 
Golf, and (as introduced in the January 1978 GAMES) Laddergrams. 
But whatever we call this puzzle, the question remains: How does one go 
about finding the best solution? Answer: One uses order and method. 

Suppose we’ve been given a simple energy problem to convert cold 
to warm in just four steps. Since all four letters in cold must change, 
there is no way to do the job in fewer than four steps. Furthermore, a 
4-step solution requires that we jump to a letter in our final destination 
at each transition. (If only three of the four letters had to change, 
we would first try for a 3-step solution.) The word following cold must 
therefore be either wold, cald, cord, or colm. Let’s keep the unabridged 
dictionary closed for the moment and proceed with the simplest choice: 
cord. Since we must still change the c, the o, and the d, there are just 
three ways to continue. Immediately we find two solutions: cold-cord - 
word worm-warm and cold cord card ward warm. 

In the same way it is easy to play alchemist, turning lead into gold 
m three steps. And to solve a puzzle from Nabokov’s novel Pale Fire, 
transforming hate to love in at least two different ways. 

Star . . . Wars 

Now let’s tackle a cosmic problem. What is the shortest way to get 
from star to wars? Again we see that at least four steps will be needed. 
But we soon find that there is no 4-step solution in this case, because 
we cannot change to a letter in wars right away. (The only possibility, 
saar, is a proper name and thus traditionally against the rules.) So let’s 
proceed systematically to find all of the legitimate words that we can 
reach from star. 

In general it is necessary to consider 100 candidates for the second 
word, namely artar or s.rar or st:rr or stax, where x is one of 25 new 
letters in each case. Without going to the big dictionary we readily come 
up with eight possibilities: scar, sear, soar, spar, stir, stab, stag, 
and stay. We might call these words close encounters of the first kind. 


Lewis Carroll’s word ward -ware dare dame game 417 

Now we must test each of the eight starter words to see if we can 
reach wars from one of them in just four steps. The only candidates for 
the third word that involve a change to a final letter are wear, seas, 
and spas; but none of them lead to wars in only three steps, so we can 
be sure that there is no 5-step solution from star to wars. Let’s go on 
then to find all possible encounters of the second kind: those words that 
can be reached from star after exactly two steps. 

Fortunately we don’t have to try 100 continuations from each of our 
eight starter words. At most 75 possibilities are of interest now (for each 
case), since there is no point in changing the same letter position twice 
in a row. For example, we need not go from scar to any word like sx'ar; 
such words were directly accessible from star. So here are the possible 
words that we can reach from our list of starters: From scar we get 
scab, scad, scan, and scat; from sear we get bear, dear, fear, gear, 
hear, near, pear, rear, tear, wear, year, seer, seal, seam, seas, and 
seat; from soar we get boar, hoar, roar, sour, soak, and soap; from 
spar we get spur, span, spas, spat, and spay; from stab we get slab, 
swab, and stub; from stag we get shag, slag, snag, and swag; and from 
stay we get shay, slay, and sway. Notice that stir is a dead end, and 
also that some of these words actually arise in more than one way (scab 
from both scar and stab; spay from both spar and stay). 

With any luck at all there will be a 4-step ladder between one of 
these 41 words and wars, which would give us a 6-step solution to the 
whole problem. But alas, they all fizzle. For instance, soap leads only 
to useless combinations of letters such as woap, saap, sorp, and soas. 
Furthermore there are three troublesome cases (wear, seas, spas) in 
which it isn’t so easy to check for a 4-mover; when only three of the 
letters have to change we must try 75 possibilities for each word (wrar, 
weir, wear, etc.). Unfortunately none of those possibilities will work. 
Thus there’s no 6-step solution from star to wars. 

What should we do now, you may be wondering. If we keep multi- 
plying the number of words that spread out from star, we’ll soon run 
out of paper (not to mention patience). 

Let’s start burning the candle at the other end by discovering what 
words could precede wars. Again there are 100 cases to try, but by now 
we’re so hooked on the problem that we have to proceed. We find that 
19 of them are legit: bars, cars, ears, jars, mars, oars, pars, tars, 
wads, wags, wans, ways, ward, ware, warm, warn, warp, wart, wary. 

While testing these possibilities, I happily stumbled on the following 
7-step solution: star sear seas teas- tens -tans-tars-wars. So this 
must be as short as possible. 


418 Selected Papers on Fun and Games 

Shortcuts and Dead Ends 

Of course, a good intuition can often lead to shortcuts. For example, one 
of the most difficult things to accomplish in a laddergram is to change 
vowels to consonants. Four-letter words with a pair of vowels in the 
middle generally have a relatively large number of “neighbor” words to 
which they could change; so we might have guessed immediately that 
sear and soar would be the most fruitful ways to start out. 

In easy laddergrams, the given words have consonants and vowels 
in the same positions (as in cold to warm). But with a harder problem 
(star to wars) the vowel positions usually disagree. In such cases it is 
best to start by changing one of the given words so that its vowels and 
consonants line up with the other one. 

Besides the problem of changing vowels to consonants (and vice 
versa), it is also difficult to get to and from letters such as q that appear 
in relatively few words. The following sequence from ducks to quack 
shows one successful way to enter the q’s: ducks- ducts-duets -suets 
suits suite-quite-quire quirk-quick -quack. (Notice that by the 
time we reach duets, the vowels and consonants are lined up with their 
counterparts in the final word quack.) We could also replace suite 
by quits in this example. I know of only three other ways to jump 
into a q word, namely guest-quest, built-quilt, and guilt quilt. 
Strictly speaking there is also suint -quint, but it uses a term not in 
my vocabulary. 

Sometimes we have no choice but to stretch our vocabulary a lit- 
tle. If we want to prepare for the switch to metric units by changing 
quart into liter, we must go to the big dictionary right away, be- 
cause the only possible first steps lead from quart to such rare words 
as quare, quirt, or the physicist’s new quark. From either quirt or 
quark-quirk we can reach quire, whence it is clear sailing through fa- 
miliar words: quite- - -diets 

- liter. (Your move.) 

Some words like yacht and sheik cannot be used at all. And 
there are also pairs of words like aloha alpha and alien align that 
lead only to each other. But the vast majority of 5- letter words are 
linked together, and we should be able to reach other 5-letter words 
through an appropriate series of one-lett.er changes. In fact, if you can 
go three steps from both your starting and ending words, it almost al- 
ways turns out that there will be a path (perhaps a long one) between 
them. This principle makes it relatively easy to determine whether or 
not a proposed laddergram is possible. Notable exceptions are words 


Lewis Carroll’s word ward ware-dare -dame game 419 

from the following groups: bound, found, hound, mound, round, sound, 
wound, would, could, mould, mount, and count; also onset, inset, 
inlet, islet, isles, idles, idler, and idled. Breaking out of the 
ight/ighs/igns group (eight, fight, light, might, night, sight, 
tight, highs, sighs, signs) also presents difficulties, although it can 
be done by going through a ladder that includes rare words: bight 
bigot -begot beget beset reset revet. 

Puzzles 

If you’ve read this far, you’re ready for the following puzzles. For fun, 
use common words wherever possible. 

1. link - - golf. 

2. liter- raths litre. 

3. mimsy- — - toves. 

4. rains plain. 

5. rouge- -cheek. 

6. sober tipsy. 

Addendum 

I was wrong: There’s a 6-step solution star soar boar boas-baas 
bars wars that I overlooked when solving the star wars puzzle by hand! 
It was first found by Donald F. Kendrick, who sent it to GAMES on 
5 June 1978. He wrote, “baas? plural form of baa. The cry of sheep.” 

The worst of it is, I think if I repeated the process I would still 
make the same mistake. My exposure to Norwegian and Dutch has 
forever ruined my ability to play Scrabble® and to regard baas as a 
word of English; that word seems totally foreign. (In Norwegian, “Han 
er ikke grei aa staa i baas rued” means “He is hard to get along with.”) 

I also erred in assuming that the term “laddergram” had first been 
introduced in a previous issue of GAMES. In fact, John E. Surrick and 
Lawrence M. Conant had published a 121-page book entitled Ladder- 
grams many years earlier (New York: J. H. Sears & Co., 1927). That 
book begins with 6-step ladders from slow to fast, flat to tire, bell 
to ring, peep to hole, slow to fast, leap to life, tramp to rails, 
and north to south; it ends with a 15-step ladder from small to large. 
(Using the Stanford GraphBase, one can show that 14 steps actually suf- 
fice for their final challenge: small-shall -shale whale whole whose 
chose chase -cease tease terse merse-merge marge large.) 


420 Selected Papers on Fun and Gaines 

Answers 


The text asks for ladders such as 

grabs-crabs cribs- cries cried creed: 
lead load goad gold: 

hate have lave love or hate have hove love; 
quite- suite -suits suets- duets diets; 

diets dints-dines lines liner liter. 

The other puzzles can be solved with simple ladders such as 

1. link wink wind wild gild gold golf. 

2. liter-later -rater rates raths laths lathe lithe litre. 

J. mimsy missy mossy mosey nosey noses roses roves toves. 

4. rains ruins ruing suing sling slang slant plant plait 

plain. 

5. rouge- route routs roots soots shots- shoes shoer sheer 
cheer-cheek. 

6. sober-sorer -corer cores-cares hares harps harpy happy 
hippy tippy-tipsy. 


Chapter 33 


Blood, Sweat, and Tears 


plate 


[Originally published in GAMES 2,4 (July 1978), 49, as a word-puzzle 
prize competition.] 

Laddergrams, or Doublets as Lewis Carroll called them (see the previous 
chapter), are quite enough to fascinate and befuddle most puzzlers. But 
we’d like to invite you to climb one more rung with us ... into the as 
yet uncharted realm of Triplets. 

The object in the original game of Doublets is to get from one word 
to another with the fewest intermediate steps. (In each step it is permis- 
sible to change one letter.) But suppose there are three words to be con- 
nected up, such as glass, plate, and spoon. And suppose you want to 
connect them in a Y-forination, as shown. 

To win this contest, all you have to [glass 
do is connect blood, sweat, and tears class slate 

to each other with the best (most efficient) claps slats 

Y-formation. Find the best word to put at the 
junction of the Y (in the example here, the junction 
word is slaps) and then find the best way to change 
this word into blood, into sweat, and into tears. 

Adjacent words must differ by only one letter, as in 
the example. The total “distance” from your junc- 
tion word to the three given words should be as small 
as possible, in order to keep the number of words 
in the Y to a minimum. Any single five-letter words that appear in 
Webster's Third New International Dictionary (Unabridged) may be 
used, except for proper names, abbreviations, contractions, or hyphen- 
ated words. The three arms of the Y need not be the same length. The 
entry with the fewest total words in the Y wins; in the event of a tie, 
the entry with the earliest postmark wins. 

I have nothing to offer but blood, toil, tears and sweat. 

— WINSTON S. CHURCHILL (1940) 


slaps 


slops 

shops 

shoos 

shook 

spook 


spoon 


421 




422 Selected Papers on Fun and Games 

Answers 

If we restrict consideration to the 5757 words of the Stanford GraphBase 
(SGB), the minimum of d(x, blood) + d(x, sweat) + d(x, tears) is 15, 
and it is achieved for four values of x: blend, blond, bland, and treed. 
(These words rank 580, 1387, 1981, and 3647, respectively, in SGB’s de- 
fault ordering by frequency of usage.) The best junction word from this 
standpoint is therefore ‘blend’, appropriately enough. And a suitable 
Y-formation for blend with 15 links is: 

blend blond blood 

blend bleed breed treed tweed tweet -sweet sweat 
blend bland brand brans beans bears tears 

Notice that this solution also happens to use the other optimum junction 
words blond, bland, and treed. 

If we restrict ourselves further to the most common 2000 five-letter 
words, we cannot use treed (rank 3647) or brans (rank 3239) or tweed 
(rank 2044). With this limitation the cost goes up to 24, but again 
blend is an optimum junction word. The minimum distance from blend 
to sweat rises from 7 to 10: blend bleed breed creed creek-cheek 
cheer— sheer shear- swear sweat; and from blend to tears, with only 
common words, the cost goes up from 6 to 12: blend bland gland 
grand-grind grins- gains pains pairs hairs heirs hears tears. 

Conversely, on the other hand, the GAMES competition allowed any 
word from Webster’s Third New International Dictionary (Unabridged). 
The prizewinning entry, found independently by six readers, needed only 
12 links, with junction word ‘scent’: 

scent slent blent blend blond blood 
scent-sceat sweat 

scent scant scans scars sears tears 

(See GAMES 2,6 (November 1978), 62. The words slent. blent, and 
sceat are unknown to SGB.) 


Chapter 34 


Biblical Ladders 


[Originally published in The Matheniagician and Pied Puzzler, a col- 
lection from the hrst “Gathering for Gardner” in tribute to Martin 
Gardner, edited by Elwyn Berlekamp and Tom Rodgers (Wellesley, Mas- 
sachusetts: A K Peters, 1999), 29-34.] 


Charles Lutwidge Dodgson, aka Lewis Carroll, invented a popular pas- 
time now called word ladders, in which one word metamorphoses into 
another by changing a letter at a time. We can go from this to that 
in three such steps: this thin than- that. 

As an ordained deacon of the Church of England, Dodgson also was 
quite familiar with the Bible. So let’s play a game that combines both 
activities: Let’s construct word ladders in which all words are Biblical. 
More precisely, the words should all be present in the Bible that was 
used in Dodgson’s day, the King James translation. 

Here, for example, is a six-step sequence that we might call Jacob’s 
Ladder, because ‘James’ is a form of ‘Jacob’: 


. . . seen of James; then of all . . 

. . because your names are written . 

. . . and their naves, and their . . . 

. . . When the waves of death . . . 

. . . had many wives. And his . . . 

. . . made their lives bitter with . . 
. . . And .Jacob lived in the land . . 


(1 Corinthians 15 : 7) 
(Luke 10 : 20) 

(1 Kings 7:33) 

(2 Samuel 22:5) 
(Judges 8:30) 
(Exodus 1 : 14) 
(Genesis 47 : 28) 


Puzzle #1. Many people consider the Bible to be a story of transition 
from wrath to faith. The following tableau shows, in fact, that there’s a 
Biblical word ladder corresponding to such a transition. But the tableau 
lists only the verse numbers, not the words; what are the missing words? 

(Remember to use a King James Bible for reference, not a new- 
fangled translation! Incidentally, the sequence of verses in this ladder is 
strictly increasing through the Old Testament, never backing up in Bib- 
lical order; Jacob’s Ladder, on the other hand, was strictly decreasing.) 


423 


424 Selected Papers on Fun and Games 

■ . . that his wrath was kindled. . . . (Genesis 39 : 19) 

. • • (Genesis 40 : 2) 

. . . (Exodus 24 : 4) 

. • • (Exodus 34 : 1) 

• • • (Leviticus 13 : 3) 

. . . (Leviticus 14 : 46) 

. . . (Leviticus 25 : 29) 

... (Deuteronomy 22:21) 

... (Joshua 11:4) 

... (1 Samuel 13 : 20) 

... (1 Samuel 15 : 3) 

... (1 Samuel 26 : 13) 

... (1 Kings 10 : 15) 

. . . (Psalm 10 : 14) 

. . . (Isaiah 3:17) 

• • . (Isaiah 54 : 16) 

• • . (Isaiah 54 : 17) 

... by his faith. Yea also, . . . (Habakkuk 2 : 4) 

Puzzle ^2. Of course $d was too easy. So the verse numbers won’t 
be given this time. Go from sword to (plow)share in four steps: 

. . . not lift up a sword against . . . (Micah 4 : 3) 


( ) 

( ) 

. . . every man Ins share, and his ... (1 Samuel 13 : 20) 

Hint: In the time of King James, people never swore; they sware. 

Puzzle 3 . Of course ^2 was also pretty easy, if you have a good 
concordance or a computer file of the King James Bible. How about 
going from naked to cover, in eight steps? A suitable middle verse is 
provided as a clue. 

. . . they were naked: and they . . . 


. . . charity shall cover the multitude 


(Genesis 3 : 7) 


(Luke 17:27) 


(1 Peter 4 : 8) 




Biblical Ladders 425 


Puzzle #4. Find a Biblical word ladder from holy to writ. 

Puzzle #5. (For worshippers of automobiles.) Construct a 12-step 
Biblical ladder from fords (Judges 3 : 28) to rolls (Ezra 6 : 1). 


Puzzle #6. Of course ^5 was too hard, unless you have special re- 
sources. Here’s one that anybody can do, with only a Bible in hand. 
Complete the following Biblical ladder, which “comes back on itself” in 
an unexpected way. 


. . . seventy times seven. Therefore . . . 


(Matthew 18 : 22) 
(Matthew 13 : ) 

(John 4 : ) 

(Numbers 33 : ) 

( Deuteronomy 29 : ) 
(1 Samuel 15 : ) 

(Job 16 : ) 

(1 Kings 7 : ) 

(Romans 9 : ) 

(Leviticus 9 : ) 

(Acts 27 : ) 

(Jeremiah 10: ) 

(Matthew 13 : ) 

(Ezekiel 24 : ) 

(Matthew 18 : ) 


Puzzle #7. Finally, a change of pace: Construct 5x5 word squares, 
using only words from the King James Bible verses shown. (The words 
will read the same down as they do across.) 

Matthew 11:11 Exodus 28 : 33 

Judges 9 : 9 Lamentations 2 : 13 

Mark 12 : 42 1 Peter 5 : 2 

Ecclesiastes 9:3 Genesis 34:21 

Luke 9 : 58 Acts 20 : 9 


426 Selected Papers on Fun and Games 

Answers 


Puzzle #1. 

. . . that his 
. . . Pharaoh was 
. . . And Moses 
. . . and I will 
... is turned 
... all the 
. . . within a 
. . . play the 
. . . the sea 
. . . man his 
. . . have, and 
... a great 
... of the 
. . . mischief and 
. . . Lord will 
. . . created the 
... is of me, 
... by his 


wrath was kindled. . . 
wroth against two . . . 
wrote all the . . . 
write upon these . . . 
white, and the . . . 
while that it is . . . 
whole year after . . . 
whore in her . . . 
shore in multitude, . . 
share, and his . . . 
spare them not; . . . 
space being between . 
spice merchants, and 
spite, to requite . . . 
smite with a scab . . . 
smith that bloweth . . 
saith the LORD. . . . 
faith. Yea also, . . . 


(Genesis 39 : 19) 
(Genesis 40 : 2) 
(Exodus 24 : 4) 
(Exodus 34:1) 
(Leviticus 13 : 3) 
(Leviticus 14 : 46) 
(Leviticus 25 : 29) 
(Deuteronomy 22:21) 
(Joshua 11:4) 

(1 Samuel 13 : 20) 

(1 Samuel 15 : 3) 

(1 Samuel 26 : 13) 

( 1 Kings 10 : 15) 
(Psalm 10 : 14) 

(Isaiah 3 : 17) 

(Isaiah 54 : 16) 

(Isaiah 54:17) 
(Habakkuk 2 : 4) 


Puzzle #2. Here’s a strictly decreasing solution: 


. . . not lift up a sword against . . . 

. Lord GOD hath sworn by himself, . . . 
. . . that are even shorn, which came . . 
. . . Eloth, on the shore of the Red . . . 

. . . every man his share, and his . . . 


(Micah 4 : 3) 

(Amos 6 : 8) 

(Song of Solomon 4 : 2) 
(1 Kings 9 : 26) 

(1 Samuel 13 : 20) 


There are 13 other possible citations for sworn, and 1 Kings 4 : 29 could 
also be used for shore, still avoiding forward steps. 


Puzzle #3. First observe that the word in Luke 17 : 27 must have at 
least one letter in common with both naked and cover. So it must 
be wives or given; and given doesn’t work, since neither gaked nor 
niked nor naved nor naven is a word. Thus the middle word must be 
wives, and the step after naked must be waked. Other words can now 
be filled in: 


Biblical Ladders 427 


. . . they were 
. . . again, and 
. . . which is 
. . . the mighty 
. they married 
hazarded their 
. looked in the 
. hospitality, a 
. . charity shall 


naked; and they . . . 
waked me, as a . . . 
waved, and which . . . 
waves of the sea. . . . 
wives, they were . . . 
lives for the name . . . 
liver. At his . . . 
lover of good men, . . . 
cover the multitude . . . 


(Genesis 3:7) 
(Zechariah 4:1) 
(Exodus 29 : 27) 
(Psalm 93:4) 
(Luke 17:27) 

( Acts 15 : 26) 
(Ezekiel 21:21) 
(Titus 1 : 8) 

(1 Peter 4 : 8) 


(Many other solutions are possible, but none are strictly increasing or 
decreasing.) 


Puzzle #4. Suitable intermediate words can be found, for example, 
in Revelation 3 : 11; Ruth 3 : 16; Ezra 7 : 24; Matthew 6 : 28; Job 40 : 17; 
Micah 1 : 8; Psalm 145 : 15. (But ‘writ’ is not a Biblical word.) 


Puzzle #5. For example, use intermediate words found in Matthew 
24:35; Ezekiel 34:25; Acts 2:45; Ecclesiastes 12:11; Matthew 25:33; 
Daniel 3:21; John 18:18; Genesis 32:15; 2 Corinthians 11:19; Psalm 
84 : 6; Numbers 1 : 2. (See also Genesis 27 : 44.) 


Puzzle #6. 

. . . seventy times 
. . . forth, and 
. . . seventh hour the 
. . . and to the 
. . . from the 
. . . And Samuel 
... I have 
. . . hewed stones, 
. . . remnant shall be 
. . . shoulder Aaron 
. . . violence of the 
. . . Gather up thy 
. . . and sowed 
. . . And your 
. . . till seven 


seven. Therefore . . . 
sever the wicked . . . 
fever left him. . . . 
fewer ye shall give . . . 
hewer of thy wood . . . 
hewed Agag in pieces . . . 
sewed sackcloth . . . 
sawed with saws, . . . 
saved: For he will . . . 
waved for a wave . . . 
waves. And the soldiers’ 
wares out of . . . 
tares among the . . . 
tires shall be . . . 
times? Jesus saith . . . 


(Matthew 18 : 22) 
(Matthew 13 : 49) 
(John 4 : 52) 

(Numbers 33 : 54) 
(Deuteronomy 29:11) 
(1 Samuel 15 : 33) 

(Job 16 : 15) 

(1 Kings 7 : 9) 
(Romans 9 : 27) 
(Leviticus 9:21) 

(Acts 27:41) 
(Jeremiah 10:17) 
(Matthew 13 : 25) 
(Ezekiel 24 : 23) 
(Matthew 18 : 21) 


428 Selected Papers on Fun and Games 

Puzzle #7. women bells 
olive equal 

mites lucre 

event large 

nests sleep 

References 

[1] Martin Gardner, The Universe in a Handkerchief: Lewis Carroll’s 
Mathematical Recreations, Games, Puzzles, and Word Plays (New 
York: Copernicus, 1996), Chapter 6. 

[2] http://etext.virginia.edu/kjv.browse.html [an online text of 
the King James Bible provided in searchable form by the Electronic 
Text Center of the University of Virginia; this URL has been routed 
to other sites since June 2008]. 


Chapter 35 


ETAOIN SHRDLU Non-Crashing Sets 


[Originally published in Word Ways 27 (1994), 138.] 

The designers of the Linotype machine arranged its keyboard for op- 
timum speed, assuming that the most common letters of English were 
e, t, a, o, i, n, s, h, r, d, 1, u in that order. The Oxford English Dictionary 
(second edition) has some amusing citations: 

The author sends in a manuscript without exclamation marks. 

The linotyper puts them in, the author takes them out in proof, 
the linotyper puts them back in, together with a couple of 
etaoins. — James Thurber, The Owl in the Attic and Other 
Perplexities (1931) 

What I love about newspapers is their etaoin shrdl. — The Lis- 
tener (15 June 1967) 

‘Lot of pleasure but also a lot of pleasure but also a lot of anxiety 
and heart-searching.’ etaoinshrdlu cmfwyp shrdlu cd showed 
that cinema and per- Mrs Nissel said that the study forming 
arts ticket prices had more or less remained in line with the 
Retail Price Index up to 1975/76. The Daily Telegraph (13 
September 1983) 

Are there twelve five-letter words, made up of just those twelve letters, 
having no common letters in any position? 

Using my personal list of 5757 words, there are 924 words made from 
only those letters, but no solutions to the problem. On the other hand, 
if one asks for only eleven disjoint words instead of twelve, my program 
finds 43,888 solutions. The nicest of these is 

usual honor thorn arena leash radii 
outdo ensue stilt idled dirts 

if we want the words to be as common as possible. 


429 


430 Selected Papers on Fun and Gaines 

I investigated the 43,888 solutions to see which five-letter strings 
would complete them to a full set. Exactly 10,406 different strings re- 
sulted. And only one of these, trull, was a word in my spell-check 
dictionary. So I found a unique solution to my problem: 

eland trull adieu ohhhh issue nadir 

snoot hunts reran dildo lotsa uteri 

Other possibilities arise if I lower my standards slightly to allow 
words that are ordinarily supposed to be capitalized. For example, if 
hindu is permitted I get three more solutions: 


ensue 

torsi 

ahhhh 

osier 

ideal 

neato 

stunt 

hindu 

radon 

droid 

lulls 

ultra 

ender 

troll 

assai 

ohhhh 

idiot 

nurse 

slain 

hindu 

round 

delta 

latus 

utero 

enter 

tulle 

asana 

ohhhh 

idiot 

nodal 

slots 

hindu 

rerun 

druid 

lasso 

uteri 

and a fourth comes 

by changing {slots, druid} to { 

sluts. dro: 

if nehru is legitimate (a nehru jacket), we have: 


ennui 

thine 

altho 

orals 

idler 

nehru 

stood 

hadda 

rosin 

durst 

lieth 

usual 

ennui 

theta 

alder 

ortho 

idiot 

nehru 

stand 

harsh 

rosin 

diode 

lulls 

usual 


and another when {alder, ortho} is changed to {altho. order}. 

The most troublesome word to include is evidently the one that ends 
with the letter u. 

Addendum 

My program in 1994 used a variant of the “dancing links” technique, 
oriented to finding maximum independent sets in a graph. 

Incidentally, my colleague Terry Winograd wrote a pioneering pro- 
gram called SHRDLU to experiment with mechanical methods for un- 
derstanding English sentences in context. [See his book Understanding 
Natural Language (New York: Academic Press, 1972).] On the webpage 

http : / /hci . Stanford . edu/ 'winograd/ shrdlu/name . html 

he explains that he chose the name because he’d seen the phrase 
ETAOIN SHRDLU in MAD magazine. 


Chapter 36 


Quadrata Obscura (Hidden Latin Squares) 


[Dedicated to the memory of Nob Yoshigahara. Presented at the 
Twenty-Ninth International Puzzle Party (IPP29), San Francisco, Cal- 
ifornia, in August 2009. Published in Word Ways 42 (2009), 248; 43 
(2010), 14.] 

A latin square is an array in which every row and every column contains 
exactly the same set of distinct letters. 

Complete each of the arrays below to a latin square in which a 
common English word appears in the bottom row. 


(a) 


p 








X 




1 




M 


P 


M 




P 


(b) 





X 





1 

p 

X 



M 

P 

1 



M 

1 

X 





X 




1 








(c) 


1 

X 





M 

M 

P 

X 






M 

P 

1 






1 


X 


E 




X 




P 















431 





432 Selected Papers on Fun and Games 

Hints 

The main difficulty is to guess the unspecified letters. Puzzle (a) can be 
completed in three ways, with the respective bottom rows M*XIP. MIX*P. 
MX*IP; the only common English word that fits is MIXUP. 

In puzzle (b) there are two unspecified letters, and the possible bot- 
tom lines are *P*MIX, *PM*IX, I**MPX, IP**MX, IP*M*X. P**MIX, P*M*IX. 
X**MIP, X*M*IP . XP*MI*. XPM*I*. Clearly PREMIX is the winner here; it’s 
way ahead of APEMIX and IPSMAX and all other possibilities. 

Similarly, the latin square constraints allow lots and lots of seven- 
letter ways to fill in the bottom line of puzzle (c) - in fact there 179 
ways altogether! -ranging from **EMIPX to XIMPE**. But the English 
language likes only one of them, even if we forget the latin square rules 
and consider all 2520 permutations of {*, *, E, I, M, P, X}. So we might as 
well write it into the bottom line: SIMPLEX. And then the puzzle becomes 
routine; the remaining entries are forced, with no need for backtracking, 
if we use a suitable order to fill them in one at a time. 


Answers 


(a) 


p 

X 

M 

1 

U 

1 

u 

P 

X 

M 

u 

p 

1 

M 

X 

X 

M 

U 

P 

1 

M 

i 

X 

U 

P 


(b) 


1 

P 

R 

X 

M 

E 

R 

E 

1 

P 

X 

M 

X 

M 

P 

1 

E 

R 

M 

1 

X 

1e 

R 

rp 

E 

X 

wf 

R 

P 

i 

P 

R 

E 

M 

1 

X 


All three answers are unique. 


(c) 


i 

X 

E 

L 

p 

S 

M 

M 

p 

X 

E 

s 

1 

L 

X 

M 

P 

1 

E 

L 

S 

L 

S 

T 

M 

X 

P 

E 

E 

L 

s 

X 

1 

M 

P 

P 

E 

L 

s 

M 

X 

1 

S 

1 

M 

p 

L 

E 

X 





Chapter 37 


5x5x5 Word Cubes by Computer 


[Originally published in Word Ways 26 (1993), 95-97.] 

I recently used a computer to look for 5 x 5 x 5 word cubes, by which I 
mean symmetric patterns that spell five-letter words in rows, columns, 
and whatchamacallits (is there a name for vertical 1 x 1 x 5s?). As far 
as I know, the only previous example was constructed by Peter Graham 
and published in Omni in July 1987. But his solution 


loved 

opera 

velar 

erase 

dares 

opera 

purer 

erode 

redan 

arena 

velar 

erode 

logos 

adore 

reset 

erase 

redan 

adore 

sarum 

enemy 

dares 

arena 

reset 

enemy 

satyr 


uses redan and sarum, which are not in my vocabulary. Also velar is 
kind of hazy for me; I know it’s a word, but I don’t think I’ve seen it in 
novels or in “real” English. 

Lots of obscure five-letter combinations can be found in unabridged 
dictionaries, but word puzzles are much more fun when they stick to 
words that I wouldn’t feel like challenging if my opponent played them 
in Scrabble®. So I’ve been collecting a list of all the five-letter words 
that I personally know and love, during odd moments since the early 
1970s. Last week I decided to see if any 5x5x5 cubes were possible 
using only words from my collection (5757 in all) . . . and I found to my 
surprise that there are many, many solutions (exactly 83576)! 

Here are the five best, according to the ranking that I used: 


aster 

scale 

tacos 

elope 

reset 

scale 

codex 

adapt 

leper 

extra 

tacos 

adapt 

caper 

opera 

strap 

elope 

leper 

opera 

perks 

erase 

reset 

extra 

strap 

erase 

taper 


433 


( 2 ) 


434 Selected Papers on Fun and Games 


types 

yeast 

pasta 

ester 

start 


yeast 

earth 

armor 

stole 

three 


pasta 

armor 

smoke 

token 

arena 

(3) 

ester 

stole 

token 

elect 

rents 

start 

three 

arena 

rents 

tease 


abler 

blade 

lapis 

edict 

rests 


blade 

login 

agent 

dinar 

entry 


lapis 

agent 

pesto 

intro 

stool 

(4) 

edict 

dinar 

intro 

cargo 

troop 

rests 

entry 

stool 

troop 

sylph 


other 

theme 

heros 

emote 

reset 


theme 

heron 

erupt 

moper 

entry 


heros 

erupt 

ruler 

opera 

strap 

(5) 

emote 

moper 

opera 

terms 

erase 

reset 

entry 

strap 

erase 

types 


after 

frame 

talcs 

emcee 

reset 


frame 

rigor 

agora 

morns 

erase 


talcs 

agora 

loyal 

crass 

salsa 

(6) 

emcee 

morns 

crass 

ensue 

esses 

reset 

erase 

salsa 

esses 

tease 


Each of these has 

one somewhat unusual word: codex, ester. 

login. 

moper, talcs. But they all pass the Scrabble® test, except that login 


might not yet be in standard dictionaries (“What is your login name?”). 

Another solution uses no unusual words whatever, but it has a flaw 
in that it uses erase twice (or more times, depending on how you count): 


racer 

adore 

comas 

erase 

reset 

adore 

divan 

overt 

rarer 

entry 

comas 

overt 

meter 

arena 

strap 

erase 

rarer 

arena 

sends 

erase 

reset 

entry 

strap 

erase 

types 

Notice that the final square here 

is the 

same as in 

(5). 


The vast majority of the 83576 solutions contain too many rare 
words to be really interesting. Furthermore, only 75130 of them are 
flawless, in the sense that they contain fifteen distinct words. 

It turns out that 4676 of the 5757 words in my collection appear in 
at least one word cube. One of them, opera, actually occurs in 17304 of 
the 83576, including (2) and (5); in fact, when the cubes are presented 
as 5 x 5 arrays of words as shown here, opera can be placed anywhere 
except in the fourth column of the fourth row. 


5x5x5 Word Cubes by Computer 435 

Why are there so many solutions? Because each solution can usually 
be tweaked into another by changing only a few letters. For example, 
one can easily find 20 different solutions that fill in the asterisks of 


*a*er 

adore 

*o*as 

erase 

reset 

adore 

divan 

overt 

rarer 

entry 

*o*as 

overt 

*e*er 

arena 

strap 

erase 

rarer 

arena 

sends 

erase 

reset 

entry 

strap 

erase 

type* 


Here’s how: The first word *a*er might be either water, paper, later, 
layer, eager, safer, maker, baker, eater, taper, laser, wager, 

waver, rarer, saber, cater, paler, caper, gayer, baser, saner, 

wafer, racer, tamer, barer, lamer, pacer, waxer, or saver; but 

we have to fit it properly with *o*as, for which the choices are more 

limited: sodas, sofas, novas, comas, yogas, togas. And that word, 
in turn, must fit with *e*er, namely with never, refer, meter, fewer, 
fever, lever, newer, sewer, deter, sever, leper, or defer. Only 
ten such combinations work out; then type* can be either types or 
typed, giving 20 solutions as stated. 

I’ve ranked the words in my corpus by frequency of use in various 
texts; the common words listed above have ranks of 3500 or less. If 
the entire list of 5757 words is used, we get not 20 but 110 different 
solutions to (8). The point here is not to obtain an exact count, but 
rather to illustrate the multiplicative phenomenon that accounts for the 
large number of word cube solutions. Similarly, the pattern 


*s*er 

scale 

*a*os 

elope 

reset 

scale 

codex 

ad*pt 

leper 

extra 

*a*os 

ad*pt 

♦ **e* 

opera 

st*a* 

elope 

leper 

opera 

perks 

erase 

reset 

extra 

st*a* 

erase 

ta*e* 


has dozens of solutions, generalizing (2). 

If my stockpile of five-letter words is restricted to the most common 
3000, only three word cubes are possible, including (3) and two others 
that are almost the same. Expanding the list to 3500 results in 83 
solutions; 6 are like (3), 20 correspond to (8), and 57 correspond to (9). 
Only 60 of the 83 are flawless, because (9) might contain leper twice. 

Word Squares 

Each slice of a symmetrical 5x5x5 word cube is a symmetrical 5x5 
word square, and of course such squares are comparatively easy to devise. 


436 Selected Papers on Fun and Games 

Indeed, my 575/ words can be used to make 541968 different symmet- 
rical 5x5 squares, only 280 of which are flawed. All but 23 of the 5757 
words participate in at least one square, the exceptions being jelly. 
j°Hy, juicy, squad, quill, skiff, godly, dizzy, quirk, gummy. 
v y in g, gauzy, whizz, woozy, jazzy, jimmy, jowly, boozy, djinn. 
spazz, buzzy , booky, and lawzy (in decreasing order of frequency). 

The following three word squares can be formed entirely from the 
most common 372 words (agree having rank 372): 


grass glass class 

right light light 

agree agree agree 

sheep sheep sheep 

steps steps steps 

The next best, with ought of rank 385 and theme of rank 483, are 
boats boats boats 

ought ought ought 

agree agree agree . 

there these theme 

steel steel steel 


Addendum 

The “dancing links” technique in the following chapter was used to ob- 
tain these results. My original article contained several errors, all of 
which have been corrected above (I hope). 

I learned later about the pioneering earlier work of Paul Remley 
[“Cubism,” Word Ways 9 (1976), 3-5] and .Jeff Grant [“Cubism revis- 
ited,” Word Ways 11 (1978), 156-157; “More word cubes,” Word Ways 
12 (1979), 76-78], They constructed symmetrical 6x6x6 cubes with 
weird words; and Grant also achieved the almost unbelievable feat of 
finding an unsymmetrical 5x5x5 cube in which all 75 words are dis- 
tinct, yet they all appear in the Oxford English Dictionary: 


strap 

areca 

tamal 

esile 

deter 

arena 

gavot 

ovate 

reden 

alene 

laval 

anele 

niton 

amese 

rases 

amene 

minal 

elemi 

rened 

ettle 

salad 

asere 

resen 

entre 

deses 


(For example, erare is a medieval Scottish form of erer, “sooner.”) 
Very interesting to logophiles. 

By the way, login is indeed present these days in The Official Scrab- 
ble® Players Dictionary, fourth edition (Springfield, Massachusetts: 
Merriam- Webster, 2005). 


Chapter 38 


Dancing Links 


[An invited lecture for a symposium at Oxford University, presented 
14 September 1999. Originally published in Millennial Perspectives in 
Computer Science, edited by Jim Davies, Bill Roscoe, and Jim Wood- 
cock, a festschrift for C. A. R. Hoare (Houndmills, Basingstoke, Hamp- 
shire: Palgrave, 2000), 187 214.] 

“ What a dance 
do they do 

Lordy, how I'm tellin' you!" [2] 

My purpose is to discuss an extremely simple technique that deserves to 
be better known. Suppose x points to an element of a doubly linked list; 
let L[x\ and i?[a;] point to the predecessor and successor of that element. 
Then the operations 

L[R[x}] y- L[x\, R[L[x}\ <- R[x] (1) 

remove x from the list; every programmer knows this. But comparatively 
few programmers have realized that the subsequent operations 

L[j?[;r]] <— x, i?[L[a;]] <— x (2) 

will put x back into the list again. 

This fact is, of course, obvious, once it has been pointed out. Yet 
I remember feeling a definite sense of “Aha!” when I first realized that 
(2) would work, because the values of L[x\ and 7?[x] no longer have 
their former semantic significance after x has been removed from its list. 
Indeed, a tidy programmer might want to clean up the data structure 
by setting L[x } and R[x) both equal to x, or to some null value, after 
x has been deleted. Danger sometimes lurks when objects are allowed 
to point into a list from the outside; such pointers can, for example, 
interfere with garbage collection. 


437 


438 Selected Papers on Fun and Games 

Why, therefore, am I sufficiently fond of operation (2) that I am mo- 
tivated to write an entire paper about it? The element denoted by x has 
been deleted from its list; why would anybody want to put it back again? 
Well, I admit that updates to a data structure are usually intended to 
be permanent. But there are also many occasions when they aren’t. 
For example, an interactive program may need to revert to a former 
state when the user wants to undo an operation or a sequence of op- 
erations. Another typical application arises in backtrack programs [16], 
which enumerate all solutions to a given set of constraints. Backtracking, 
also called depth-first search , will be the focus of the present paper. 

The idea of (2) was introduced in 1979 by Hirosi Hitotumatu and 
Kohei Noshita [22], who showed that it makes Dijkstra’s well-known 
program for the N queens problem [6, pages 72-82] run nearly twice as 
fast without making the program significantly more complicated. 

Floyd’s elegant discussion of the connection between backtracking 
and nondeterministic algorithms [11] includes a precise method for up- 
dating data structures before choosing between alternative lines of com- 
putation, as well as for downdating the data when a new line should be 
explored. In general, the key problem of backtrack programming can be 
regarded as the task of deciding how to narrow the search and at the 
same time to organize the data that controls those decisions. Each step 
in the solution to a multistep problem changes the problem that remains 
to be solved. 

In simple situations we need only maintain a stack that contains 
snapshots of the relevant state information at all ancestors of the current 
node in the search tree. But the task of copying the entire state at each 
level might take too much time. Therefore we often choose to work with 
global data structures, which are modified whenever the search enters a 
new level and restored when the search returns to a previous level. 

For example, Dijkstra’s recursive procedure for the queens prob- 
lem kept the current state in three global Boolean arrays, representing 
the columns, the diagonals, and the reverse diagonals of a chessboard; 
Hitotumatu and Noshita’s program kept it in a doubly linked list of 
available columns together with Boolean arrays for both kinds of diag- 
onals. When Dijkstra tentatively placed a queen, he changed one entry 
of each Boolean array from true to false; then he made the entry true 
again when backtracking. Hitotumatu and Noshita used the assignments 
of (1) to remove a column and those of (2) to restore it again; this meant 
that they could find an empty column without having to search for it. 
Each program strove to record the state information in such a way that 
the placing and subsequent unplacing of a queen would be efficient. 


Dancing Links 439 

The beauty of (2) is that operation (1) can be undone by knowing 
only the value of x. General schemes for undoing assignments require 
us to record the identity of the left-hand side together with its previous 
value (see [11]; see also [25, sections 268-284]). But in this case only 
the single quantity x is needed, and backtrack programs often know the 
value of x implicitly as a byproduct of their normal operation. 

We can apply (1) and (2) repeatedly in complex data structures 
that involve large numbers of interacting doubly linked lists. The pro- 
gram logic that traverses those lists and decides what elements should 
be deleted can often be run in reverse, thereby deciding what elements 
should be undeleted. And undeletion restores links that allow us to 
continue running the program logic backwards until we’re ready to go 
forward again. 

This process causes the pointer variables inside the global data 
structure to execute an exquisitely choreographed dance; hence I like 
to call (1) and (2) the technique of dancing links. 

The Exact Cover Problem 

One way to illustrate the power of dancing links is to consider a general 
problem that can be described abstractly as follows: Given a matrix of 
Os and Is, does it have a set of rows containing exactly one 1 in each 
column? 

For example, the matrix 

/ 0 0 1 0 1 1 0 \ 

1 0 0 1 0 0 1 

0 110 0 10 
1 0 0 1 0 0 0 

0 1 0 0 0 0 1 

Vo 0 0 1 1 0 1/ 

has such a set (rows 1, 4, and 5). We can think of the columns as elements 
of a universe, and the rows as subsets of the universe; then the problem is 
to cover the universe with disjoint subsets. Or we can think of the rows as 
elements of a universe, and the columns as subsets of that universe; then 
the problem is to find a collection of elements that intersect each subset 
in exactly one point. Either way, it’s a potentially tough problem, well 
known to be NP-complete even when each row contains exactly three Is 
[13, section A3.1, problem SP2, known as “X3C” for short]. And it is a 
natural candidate for backtracking. 

Dana Scott conducted one of the first experiments on backtrack 
programming in 1958, when he was a graduate student at Princeton 


440 Selected Papers on Fun and Games 

University [35]. His program, written for the IAS “MANIAC” computer 
with the help of Hale F. Trotter, produced the first listing of all ways 
to place the 12 pentominoes into a chessboard leaving the center four 
squares vacant. For example, one of the 65 solutions is shown in Figure 1. 
(Pentominoes are the case n — 5 of ti-on i i noes. which are the rookwise- 
connected n-cell subsets of an infinite board; see [15]. Scott was probably 
inspired by Golomb s paper [14] and by later developments reported by 
Martin Gardner [12].) 


Figure 1. 

Scott’s pentomino problem. 



This problem is a special case of the exact cover problem. Imagine a 
matrix that has 72 columns, one for each of the 12 pentominoes and one 
for each of the 60 cells of the chessboard-minus-its-center. Construct all 
possible rows representing a way to place a pentomino on the board; each 
row contains a 1 in the column identifying the piece, and five Is in the 
columns identifying its positions. (There are exactly 1568 such rows.) 
We can name the first twelve columns FILPNTUVWXYZ, following 
Golomb ’s recommended names for the pentominoes [15, page 7], and we 
can use two digits ij to name the column corresponding to rank i and 
file j of the board; each row is conveniently represented by giving the 
names of the columns where Is appear. For example, Figure 1 is the 
exact cover corresponding to the following twelve matrix rows: 


I 11 12 13 14 15 
N 16 26 27 37 47 
L 17 18 28 38 48 
U 21 22 31 41 42 


X 23 32 33 34 43 
W 24 25 35 36 46 
P 51 52 53 62 63 
F 56 64 65 66 75 


Z 57 58 67 76 77 
T 61 71 72 73 81 

V 68 78 86 87 88 

Y 74 82 83 84 85 


Solving an Exact Cover Problem 


The following nondeterministic algorithm, which I will call algorithm X 
for lack of a bettei name, finds all solutions to the exact cover problem 
defined by any given matrix A of Os and Is. Algorithm X is simply a 
statement of the obvious trial-and-error approach. (Indeed, I can’t think 
of any other reasonable way to do the job, in general.) 



Dancing Links 441 


Algorithm X: 

If A is empty, the problem is solved; terminate successfully. 

Otherwise choose a column, c (deterministically). 

Choose a row, r, such that A[r,c\ = 1 (nondeterministically). 

Include r in the partial solution. 

For each j such that A[r,j] = 1, 

for each i such that A[i,j] — 1, delete row i from matrix A; 
delete column j from matrix A. 

Repeat this algorithm recursively on the reduced matrix A. 

The nondeterministic choice of r means that the algorithm essentially 
clones itself into independent subalgorithms; each subalgorithm inherits 
the current matrix A, but reduces it with respect to a different row r. 
If column c is entirely zero, there are no subalgorithms and the process 
terminates unsuccessfully. 

The subalgorithms form a search tree in a natural way, with the 
original problem at the root and with level k containing each subalgo- 
rithm that corresponds to k chosen rows. Backtracking is the process of 
traversing the tree in preorder, “depth first.” 

Any systematic rule for choosing column c in this procedure will find 
all solutions, but some rules work much better than others. For example, 
Scott [35] said that his initial inclination was to place the first pentomino 
first, then the second pentomino, and so on; this would correspond to 
choosing column F first, then column I, etc., in the corresponding exact 
cover problem. But he soon realized that such an approach would be 
hopelessly slow: There are 192 ways to place the F, and for each of those 
choices there are approximately 34 ways to place the I. The Monte Carlo 
estimation procedure described in [24] suggests that the search tree for 
such a scheme has roughly 2 x 10 12 nodes! By contrast, the alternative 
of choosing column 11 first (the column corresponding to rank 1 and 
file 1 of the board), and in general choosing the lexicographically first 
uncovered column, leads to a search tree with 9,015,751 nodes. 

Even better is the strategy that Scott finally adopted [35]: He re- 
alized that piece X has only 3 essentially different positions, namely 
centered at 23, 24, or 33. Furthermore, if the X pentomino is at 33, we 
can assume that the P is not “turned over,” thus restricting the P to 
only four of its eight orientations. Then we get each of the 65 essentially 
different solutions exactly once, and the full set of 8 x 65 = 520 solutions 
is easily obtained by rotation and reflection. 

Solomon Golornb and Leonard Baumert [16] suggested choosing, at 
each stage of a backtrack procedure, a subproblem that leads to the 


442 Selected Papers on Fun and Games 

fewest branches, whenever this choice can be made efficiently. In the 
case of an exact cover problem, this means that we want to choose at 
each stage a column with fewest Is in the current matrix A. Fortunately 
we will see that the technique of dancing links allows us to do this 
quite nicely. 

For example, Scott’s original lexicographic strategy for choosing c 
led to the following search trees in the pentomino problem: 

103,005 nodes and 19 solutions (for X at 23); 

106,232 nodes and 20 solutions (for X at 24); 

126,636 nodes and 26 solutions (for X at 33, P not flipped). 

The Golomb-Baumert strategy reduces this to just 

10,421 nodes and 19 solutions (for X at 23); 

12,900 nodes and 20 solutions (for X at 24); 

14,045 nodes and 26 solutions (for X at 33, P not flipped). 


The Dance Steps 

One good way to implement algorithm X is to represent each 1 in the 
matrix A as a data object x with five fields L[x\,R[x\,U[x],D[x\,C[ x\. 
Rows of the matrix are doubly linked as circular lists via the L and 
R fields ( “left” and “right” ) ; columns are doubly linked as circular lists 
via the U and D fields (“up and “down” ). Each column list also includes 
a special data object called its list header. 

The list header nodes are part of a larger object called a column 
object. Each column object y contains the fields L[y], R[y\,U[y\, D[y\, 
and C[y) of a data object and two additional fields, S[y] (“size”) and 
N[y] ("name”); the size is the number of Is in the column, and the 
name is a symbolic identifier for printing the answers. The C field of 
each object points to the column object at the head of the relevant 
column. 

The L and R fields of the list headers link together all columns that 
still need to be covered. This circular list also includes a special column 
object called the root , h. which serves as a master header for all the 
active headers. The fields U[h],D[h],C[h], S[h], and N[h] are not used. 

For example, the 0-1 matrix of (3) would be represented by the 
objects shown in Figure 2, if we name the columns A, B, C, D. E, F, 
and G. (This diagram “wraps around” toroidally at the top, bottom, 


Dancing Links 443 



FIGURE 2. Four- way-linked representation of the exact cover problem (3). 

left, and right. The C links are not shown because they would clutter 
up the picture; each C field points to the topmost element in its column.) 

Our nondeterministic algorithm to find all exact covers can now be 
cast in the following explicit, deterministic form as a recursive procedure 
search(k), which is invoked initially with k — 0: 

If R[h] = h, print the current solution (see below) and return. 
Otherwise choose a column object c (see below). 

Cover column c (see below). 

For each r 4— D[c], D [£)[c]] , . . . , while r / c, 
set Ok 4— r; 

for each j 4— R[r], i?[i?[r]] , . . . , while j ^ r, 
cover column C[j] (see below); 
search(k + 1); 
set r 4- Ot and c 4— C[r] ; 
for each j 4— L[r], L[L[r]] , . . . , while j / r, 
uncover column C[j] (see below). 

Uncover column c (see below) and return. 























444 Selected Papers on Fun and Games 

The operation of printing the current solution is easy: We successively 
print the rows containing Oo , 0±, . . . , Ok~i , where the row containing 
data object O is printed by printing the names 7V[C[0]1, iVTCLfflO]]] 
JV[C[iJ[fl[0]]]], etc. 

To choose a column object c, we could simply set c R[h\; this is 
the leftmost uncovered column. Or if we want to minimize the branching 
factor, we could set s <- oo and then 

for each j <- R[h], , . . . , while j ± h, 

if <S[j] < s set c 4- j and s <- m 

Then c is a column with the smallest number of Is. (The S fields are 
not needed unless we want to minimize branching in this way.) 

The operation of covering column c is more interesting: It removes c 
from the header list and removes all rows in c’s own list from the other 
column lists they are in. 

Set T[i?[c]] «- L[c ] and i?[Z[c]] «- JR[c]. 

For each i <- £>[c], D [Z? [c]] , . . . , while i ± c, 
for each j <- R[R[i }] , . . . , while j ± i, 

set U[D[j]]^U[j], D[U[j]} ^ D\j], 
and set 5[C[j']] f- 5[C[j']] - 1. 

Operation (1), which I mentioned at the outset of this paper, is used 
here to remove objects in both the horizontal and vertical directions. 

Finally, we get to the point of this whole algorithm, the operation 
of uncovering a given column c. Here is where the links do their dance: 

For each i U[c], C/ [t/[c]] , . . . , while i ^ c, 
for each j <- L[i], L[L[i ]] , . . . , while j ± i, 
setS[C[j]]^S[C[j}}+l, 
and set U[D[j]] <-j, D[U\j]\ <- j. 

Set L[H[c]] <r- c and H[L[c]] c. 

Notice that uncovering takes place in precisely the reverse order of the 
covering operation, using the fact that (2) undoes (1). (Actually we 
need not adhere so strictly to the principle of “last done, first undone” 
in this case, since j could run through row i in any order. But we 
must be careful to unremove the rows from bottom to top, because we 
removed them from top to bottom. Similarly, it is important to uncover 
the columns of row r from right to left, because we covered them from 
left to right.) 

Consider, for example, what happens when search^ 0) is applied to 
the data of (3) as represented by Figure 2. Column A is covered by 


Dancing Links 445 



FIGURE 3. The links after column A in Figure 2 has been covered. 


removing both of its rows from their other columns; the structure now 
takes the form of Figure 3. Notice the asymmetry of the links that 
appear in column D of the updated structure: The upper element was 
deleted first, so it still points to its original neighbors, but the other 
deleted element points upward to the column header. 

Continuing searched), when r points to element A of row (A,D,G), 
we also cover columns D and G. Figure 4 shows the status as we enter 
search( 1); this data structure represents the reduced matrix 


BCE 
/ 0 1 1 
\1 10 



(4) 


Now search(l) will cover column B, and there will be no Is left in 
column E. So search^ 2) will find nothing. Then search(l) will return, 
having found no solutions, and the state of Figure 4 will be restored. 
The outer level routine, search^ 0), will proceed to convert Figure 4 back 
to Figure 3, and it will move r down to element A of row (A,D). 



















446 Selected Papers on Fun and Games 



Figure 4. The links after columns D and G in Figure 3 have been covered. 

Soon the solution will be found. It will be printed as 

A D 
B G 
C E F 

if the S fields are ignored in the choice of c, or as 

A D 
E F C 
B G 

if the shortest column is chosen at each step. (The first item printed in 
each row list is the name of the column on which branching was done.) 
Readers who play through the action of this algorithm on some examples 
will understand why I chose the title of this paper. 

Efficiency Considerations 

When algorithm X is implemented in terms of dancing links, let’s call 
it algorithm DLX. The running time of algorithm DLX is essentially 



















Figure 5. The search tree for one case of Scott’s pentomino problem. 


proportional to the number of times it applies operation (1) to remove an 
object from a list; this is also the number of times it applies operation (2) 
to unremove an object. Let’s say that this quantity is the number of 
updates. A total of 30 updates are performed during the solution of (3) 
if we repeatedly choose the shortest column: 12 updates are made on 
level 0, 14 on level 1, and 4 on level 2. Alternatively, if we ignore the 
5 heuristic, the algorithm makes 16 updates on level 1 and 7 updates 
on level 2, for a total of 35. But in the latter case each update will go 
noticeably faster, since the statements S[C[j]] 5[C[j]] ± 1 can be 

omitted; hence the overall running time will probably be less. Of course 
we need to study larger examples before drawing any general conclusions 
about the desirability of the S heuristic. 

A backtrack program usually spends most of its time on only a few 
levels of the search tree (see [24]). For example, Figure 5 shows the 
search tree for the case X = 23 of Dana Scott’s pentomino problem 
using the S heuristic. It has the profile shown in Table 1, where the 
number of updates shown for level k > 0 is the number of times an 
element was removed from a doubly linked list during the calculations 
between levels k — 1 and k. The 2,031 updates on level 0 correspond to 
removing column X from the header list and then removing 2030/5 = 
406 rows from their other columns; these are the rows that overlap with 
the placement of X at 23. Notice that more than half of the nodes lie 
on levels > 8, but more than half of the updates occur on the way to 
level 7. Extra work on the lower levels has reduced the need for hard 
work at the higher levels. 


448 Selected Papers on Fun and Games 


Table 1 . Profile of the search tree in Figure 5 


Level 

Nodes 

Updates 

Updates per node 

0 

1 

( o%) 

2,031 

( o%) 

2031.0 

1 

2 

( 0%) 

1,676 

( o%) 

838.0 

2 

22 

( o%) 

28,492 

( 1%) 

1295.1 

3 

77 

( 1%) 

77,687 

( 2%) 

1008.9 

4 

219 

( 2%) 

152,957 

( 4%) 

698.4 

5 

518 

( 5%) 

367,939 

(10%) 

710.3 

6 

1,395 

(13%) 

853,788 

(24%) 

612.0 

7 

2,483 

(24%) 

941,265 

(26%) 

379.1 

8 

2,574 

(25%) 

740,523 

(20%) 

287.7 

9 

2,475 

(24%) 

418,334 

(12%) 

169.0 

10 

636 

( 6%) 

32,205 

( 1%) 

50.6 

11 

19 

( 0%) 

826 

( o%) 

43.5 

Total 

10,421 

(100%) 

3,617,723 (100%) 

347.2 


When the same problem is run without the ordering heuristic based 
on S fields, we obtain the statistics shown in Table 2. Each up- 
date involves about 16 memory accesses when the S heuristic is used, 
and about 10 accesses when S is ignored. Thus the S heuristic re- 
duces the total number of memory to approximately (16 x 3,617,723)/ 
(10 x 17,818,752) 32% of what would otherwise have been needed in 

this example. The heuristic is even more effective in larger problems, 
because it tends to reduce the total number of nodes by a factor that is 
exponential in the number of levels while the cost of applying it grows 
only linearly. 

Assuming that the S heuristic is good in large trees but not so good 
in small ones, I tried a hybrid scheme that uses S at low levels but not at 
high levels. This experiment was, however, unsuccessful. If, for example, 
S was ignored after level 7, the statistics for levels 8-11 were as follows: 


Level 

Nodes 

Updates 

8 

18,300 

5,672,258 

9 

28,624 

2,654,310 

10 

9,989 

213,944 

11 

19 

10,179 


And if the change was applied after level 8, the stats were similar: 


Level 

Nodes 

Updates 

9 

11,562 1,495,054 

10 

6,113 

148,162 

11 

19 

6,303 


Dancing Links 449 


TABLE 2. Profile of the search tree without the S heuristic 


Level 

Nodes 

Updates 

Updates per node 

0 

1 

( o%) 

2,031 

( o%) 

2031.0 

1 

6 

( o%) 

5,606 

( 0%) 

934.3 

2 

24 

( o%) 

30,111 

( o%) 

1254.6 

3 

256 

( o%) 

249,904 

( 1%) 

976.2 

4 

581 

( 1%) 

432,471 

( 2%) 

744.4 

5 

1,533 

( 1%) 

1,256,556 

( 7%) 

819.7 

6 

3,422 

( 3%) 

2,290,338 

(13%) 

669.3 

7 

10,381 

(10%) 

4,442,572 

(25%) 

428.0 

8 

26,238 

(25%) 

5,804,161 

(33%) 

221.2 

9 

46,609 

(45%) 

3,006,418 

(17%) 

64.5 

10 

13,935 

(14%) 

284,459 

( 2%) 

20.4 

11 

19 

( o%) 

14,125 

( o%) 

743.4 

Total 

103,005 (100%) 

17,818,752 (100%) 

173.0 


Therefore I decided to retain the S heuristic at all levels of algo- 
rithm DLX. 

My trusty old SPARCstation 2 computer, vintage 1992, is able to 
perform approximately 0.39 mega-updates per second when working on 
large problems and maintaining the S fields. The 120 MHz Pentium I 
computer that Stanford computer science faculty were given in 1996 did 
1.21 mega-updates per second, and my new 500 MHz Pentium III does 
5.94. Thus the running time decreases as technology advances; but it 
remains essentially proportional to the number of updates, which is the 
number of times the links do their dance. Therefore I prefer to measure 
the performance of algorithm DLX by counting the number of updates, 
not by counting the number of elapsed seconds. 

Scott [35] was pleased to discover that his program for Prince- 
ton’s MANIAC solved the pentomino problem in about 3.5 hours. The 
MANIAC executed approximately 4000 instructions per second, so this 
represented roughly 50 million instructions. He and H. F. Trotter 
found a nice way to use the “bitwise-and” instructions of the MA- 
NIAC, which had 40-bit. registers. Their code, which executed about 
50,000,000/(103,005 + 106,232 + 126,636) ss 150 instructions per node of 
the search tree, was quite efficient in spite of the fact that they had to 
deal with about ten times as many nodes as would be produced by the 
ordering heuristic. Indeed, the linked-list, approach of algorithm DLX 
performs a total of 3,617,723 + 4,547,186 + 4,865,610 = 13,030,519 up- 
dates, or about 208 million memory accesses; and it would never fit in the 
5120-byte memory of the MANIAC! From this standpoint the technique 


450 Selected Papers on Fun and Games 

of dancing links is actually a step backward from Scott’s 40-year-old 
method, although of course that method works only for very special 
types of exact cover problems in which simple geometric structure can 
be exploited. 

The task of finding all ways to pack the set of pentominoes into a 
6 x 10 rectangle is more difficult than Scott’s 8 x 8-2 x 2 problem, because 
the backtrack tree for the 6 x 10 problem is larger and there are 2339 
essentially different solutions [21]. In this case we limit the X pentomino 
to the upper left quarter of the board; our linked-list algorithm gener- 
ates 904,969 nodes and 309,134,131 updates (or 28,323,148 nodes and 
4,107,105,935 updates without the S heuristic). This solves the problem 
in less than a minute on a Pentium III; however, again I should point out 
that the special characteristics of pentominoes allow a faster approach. 

John G. Fletcher needed only ten minutes to solve the 6 X 10 prob- 
lem on an IBM 7094 in 1965, using a highly optimized program that 
had 765 instructions in its inner loop [10], The 7094 had a clock rate 
of 0.7 MHz, and it could access two 36-bit words in a single clock cycle. 
Fletcher’s program required only about 600 x 700,000/28,323,148 ss 15 
clock cycles per node of the search tree; so it was superior to the bit- 
wise method of Scott and Trotter, and it remains the fastest algorithm 
known for problems that involve placing the twelve pentominoes. (N. G. 
de Bruijn discovered an almost identical method independently; see [7].) 

With a few extensions to the 0 1 matrix for Dana Scott’s problem, 
we can solve the more general problem of covering a chessboard with 
twelve pentominoes and one square tetromino, without insisting that 
the tetromino occupy the center. This is essentially the classic problem 
of Dudeney, who invented pentominoes in 1907 [9]. The total number of 
such chessboard dissections that are essentially different has apparently 
never appeared in the literature; algorithm DLX needs 1,526,279.783 
updates to determine that it is exactly 16,146. 

Many people have written about polyomino problems, including 
distinguished mathematicians such as Golornb [15]; de Bruijn [8]; Berle- 
kamp, Conway, and Guy [4]. Their arguments for placing the pieces 
are sometimes based on enumerating the number of ways a certain cell 
on the board can be filled, sometimes on the number of ways a certain 
piece can be placed. But as far as I know, the basic fact that such tasks 
are exact cover problems, in which cells and piece names play identical 
roles, has been pointed out only once in the published literature [32], 
without actually making use of this perfect symmetry between cells and 
pieces. Algorithm DLX will branch on the ways to fill a cell if some cell 
is difficult to fill, or on the ways to place a piece if some piece is difficult 



92 solutions, 14,352,556 nodes 100 solutions, 10,258,180 nodes 

1,764,631,796 updates 1,318,478,396 updates 




20 solutions, 6,375,335 nodes 0 solutions, 1,234,485 nodes 

806,699,079 updates 162,017,125 updates 

Figure 6. Packing 45 Y pentominoes into a 15 x 15 square. 

to place. The algorithm knows no difference, because piece names and 
cells are simply columns of the given input matrix. 

Algorithm DLX begins to outperform other pentomino-placing pro- 
cedures in problems where the search tree has many levels. For example, 
let’s consider the problem of packing 45 Y pentominoes into a 15 x 15 
square. Jenifer Haselgrove studied this with the help of a machine called 
the ICS Multum — which qualified as a “fast, minicomputer” in 1973 [20]. 
The Multum produced an answer after more than an hour, but she re- 
mained uncertain whether other solutions were possible. Now, with the 
dancing links approach, we can obtain several solutions almost instantly, 
and the total number of distinct solutions turns out to be 212. The solu- 
tions fall into four classes, depending on the behavior at the four corners; 
representatives of each achievable class are shown in Figure 6. 








452 Selected Papers on Fun and Games 

Applications to Hexiamonds 

In the late 1950s, T. H. O’Beirne introduced a pleasant variation on poly- 
ominoes by substituting triangles for squares. He named the resulting 
shapes polyiamonds: moniamonds, diamonds, triamonds, tetriamonds, 
pentiamonds, hexiamonds, etc. The twelve hexiamonds were indepen- 
dently discovered by J. E. Reeve and J. A. Tyrrell [33], who found more 
than forty ways to arrange them into a 6 x 6 rhombus. Figure 7 shows one 
such arrangement, together with some arrow dissections that I couldn't 
resist trying when I first learned about hexiamonds. The 6x6 rhombus 
can be tiled by the twelve hexiamonds in exactly 156 ways. (This fact 
was first proved by P. J. Torbijn [36], who worked without a computer; 
algorithm DLX confirms his result after making 37,313,405 updates, if 
we restrict the “sphinx” to only 3 of its 12 orientations.) 

O’Beirne was particularly fascinated by the fact that seven of the 
twelve hexiamonds have different shapes when they are flipped over, and 
that the resulting 19 one-sided hexiamonds have the correct number of 
triangles to form a hexagon: a hexagon of hexiamonds (see Figure 8). In 
November of 1959, after three months of trials, working by hand in his 
study, he found a solution; and two years later he challenged the readers 
of New Scientist to match this feat [28, 29, 30]. 

Meanwhile he had shown the puzzle to Richard Guy and his fam- 
ily. The Guys published several solutions in a journal published in 
Singapore, where Richard was currently a professor [17], When Richard 
subsequently recounted the story of this fascinating recreation in [18], he 
remarked that, when O'Beirne had first described the puzzle, “Everyone 
wanted to try it at once. No one went to bed for about 48 hours.” 

A 19-level backtrack tree with many possibilities at each level makes 
an excellent test case for the dancing links approach to covering, so I 
fed O'Beirne’s problem to my program. I broke the general case into 
seven subcases, depending on the distance of the hexagon piece from 
the center; furthermore, when that distance was zero, I considered two 
subcases depending on the position of the “crown.” Figure 8 shows a 
representative of each of the seven cases, together with statistics about 
the search. The total number of updates performed was 134,425,768,494. 

My goal was not only to count the solutions, but also to find arrange- 
ments that were as symmetrical as possible -in response to a problem 
that was stated in Berlekamp, Guy, and Conway’s book Winning Ways 
[4, page 788], Let us define the horizontal symmetry of a configura- 
tion to be the number of edges between pieces that also are edges be- 
tween pieces in the left-right reflection of that configuration. The overall 


Dancing Links 453 



4 solutions, 6,677 nodes 
4,687,159 updates 



0 solutions, 7,603 nodes 
3,115,387 updates 



156 solutions, 70,505 nodes 
37,313,405 updates 




41 solutions, 35,332 nodes 3 solutions, 5,546 nodes 

14,948,759 updates 3,604,817 updates 

Figure 7. The twelve hexiamonds, packed into a 6 X 6 rhombus and into 
various arrowlike shapes. 

hexagon has 156 internal edges, and the 19 one-sided hexiamonds have 
96 internal non-edges. Therefore if an arrangement were perfectly sym- 
metrical — unchanged by left-right reflection its horizontal symmetry 
would be 60. But no such perfectly symmetric solution is possible. 

The vertical symmetry of a configuration is defined similarly, but 
with respect to top-bottom reflection. A solution to the hexiamond prob- 
lem is maximally symmetric if it has the highest horizontal or vertical 
symmetry score, and if the smaller score is as large as possible consis- 
tent with the larger score. Each of the solutions shown in Figure 8 is, in 
fact, maximally symmetric in its class. (And so is the solution to Dana 
Scott’s problem that is shown in Figure 1: It has vertical symmetry 36 
and horizontal symmetry 30.) 



454 Selected Papers on Fun and Gaines 


lsym = 51, vsym = 24) 
1,914 solutions 
4,239,132 nodes 
2,142,276,414 updates 


(hsym = 52, vsym = 24) 
5,727 solutions 
21,583,173 nodes 
11,020,236,507 updates 


(hsym = 32, vsym = 50) (hsym = 51, vsym = 22) 


11,447 solutions 
20,737,702 nodes 
10,315,775,812 updates 


7,549 solutions 
24,597,239 nodes 
12,639,698,345 updates 


(hsym = 48, vsym = 30) 
6,675 solutions 
17,277,362 nodes 
8,976,245,858 updates 


(hsym = 52, vsym = 27) 
15,717 solutions 
43,265,607 nodes 
21,607,912,011 updates 


(hsym = 48, vsym = 29) 
75,490 solutions 
137,594,347 nodes 
67,723,623,547 updates 


FIGURE 8. Solutions to O’Beirne’s hexiamond-hexagon problem, with the 
small hexagon at various distances from the center of the large one. 



Dancing Links 455 

The largest possible vertical symmetry score is 50; it is achieved in 
Figure 8(c), and in seven other solutions obtained by independently rear- 
ranging three of its symmetrical subparts. Four of the eight have a hor- 
izontal symmetry score of 32; the others have horizontal symmetry 24. 
John Conway found these solutions by hand in 1964 and conjectured 
that they were maximally symmetric overall. But that honor belongs 
uniquely to the solution in Figure 8(f), at least by my definition, because 
Figure 8(f) has horizontal symmetry 52 and vertical symmetry 27. The 
only other ways to achieve horizontal symmetry 52 have vertical sym- 
metry scores of 20, 22, and 24. (Two of those other ways do, however, 
have the surprising property that 13 of their 19 pieces are unchanged by 
horizontal reflection; this is symmetry of entire pieces, not just of edges.) 

After I had done this enumeration, I read Guy’s paper [18] for the 
first time and learned that Marc M. Paulhus had already enumerated all 
solutions in May 1996 [31]. Good: Our independent computations would 
confirm the results. But no - my program found 124,519 solutions, while 
his had found 124,518! He reran his program in 1999 and now we agree. 

O'Beirne [29] also suggested an analogous problem for pentominoes, 
since there are 18 one-sided pentominoes. He asked if they can be put 
into a 9 x 10 rectangle, and Golomb provided an example in [15, Chap- 
ter 6]. Jenifer Leech wrote a program to prove that there are exactly 
46 different, ways to pack the one-sided pentominoes in a 3 X 30 rect- 
angle; see [26]. Figure 9 shows a maximally symmetric example (which 
isn’t really very symmetrical). 



46 solutions, 1,428,709 nodes, 462,355,739 updates, hsym = 51, vsym = 48 
Figure 9. The one-sided pentominoes, packed into a 3 x 30 rectangle. 


I set out to count the solutions to O’Beirne’s 9x10 challenge, figuring 
that an 18-stage exact cover problem with six Is per row would be 
simpler than a 19-stage problem with seven Is per row. But I soon 
found that the task would be hopeless, unless I invented a much better 
algorithm. The Monte Carlo estimation procedure of [24] suggests that 
about 19 quadrillion updates will be needed, with 64 trillion nodes in 
the search trees. If that estimate is correct, I could have the result in a 
few months; but I’d rather try for a new Mersenne prime. 

I do, however, have a conjecture about the solution that will have 
maximum horizontal symmetry; see Figure 10. 



456 


Selected Papers on Fun and Games 



hsym = 74 , vsym = 49 


Figure 10. Is this the most symmetrical way to pack the one-sided pen- 
tominoes into a 9 x 10 rectangle? 

A Failed Experiment 

Special arguments based on “coloring” often give important insights into 
tiling problems. For example, it is well known [5, pages 142 and 394] 
that if we remove two cells from opposite corners of a chessboard, there 
is no way to cover the remaining 62 cells with dominoes. The reason is 
that the mutilated chessboard has, say, 32 white cells and 30 black cells, 
but each individual domino covers one cell of each color. If we present 
such a covering problem to algorithm DLX, it makes 4,780,846 updates 
(and finds 13,922 ways to place 30 of the 31 dominoes) before concluding 
that there is no solution. 

The cells of the hexiamond-hexagon problem can be colored black 
and white in a similar fashion: All triangles that point left are black, 
say, and all that point right are white. Then fifteen of the one-sided 
hexiamonds cover three triangles of each color; but the remaining four, 
namely the ‘sphinx and the “yacht’ and their mirror images, each have 
a four-to-two color bias. Therefore every solution to the problem must 
put exactly two of those four pieces into positions that favor black. 

I thought I’d speed things up by dividing the problem into six sub- 
problems, one for each way to choose the two pieces that will favor black. 
Each of the subproblems was expected to have about 1/6 as many solu- 
tions as the overall problem, and each subproblem was simpler because 
it gave four of the pieces only half as many options as before. Thus I 
expected the subproblems to run up to 16 times as fast as the original 
problem, and I expected the extra information about impossible correla- 
tions of piece placement to help algorithm DLX make intelligent choices. 



Dancing Links 457 

But this setup turned out to be a case where mathematics gave 
me bad advice. The overall problem had 6675 solutions and required 
8,976,245,858 updates (Figure 8(e)). The six subproblems turned out to 
have respectively 955, 1208, 1164, 1106, 1272, and 970 solutions, roughly 
as expected; but they each required between 1.7 and 2.2 billion updates, 
and the total work to solve all six subproblems was 11,519,571,784. 
So much for that bright idea. 

Applications to Tetrasticks 

Instead of making pieces by joining squares or triangles together, Brian 
Barwell [3] considered making them from line segments or sticks. He 
called the resulting objects polysticks , and noted that there are 2 disticks, 
5 tristicks, and 16 tetrasticks. The tetrasticks are especially interesting 
from a recreational standpoint; I received an attractive puzzle in 1993 
that was equivalent to placing a certain set of ten tetrasticks in a 4 x 4 
square [1], and I spent many hours trying to psych it out. 

Barwell proved that the sixteen tetrasticks cannot be assembled into 
any symmetrical shape. But by leaving out any one of the five tetrasticks 
that have an excess of horizontal or vertical line segments, he found 
several ways to fill a 5 x 5 square. For example, here’s a solution when 
the L tetrastick is placed at the side: 




Such puzzles are quite difficult to do by hand, and he had found only 
five solutions at the time he wrote his paper; he conjectured that fewer 
than a hundred solutions would actually exist. But his guess turned out 
to be far too low: The set of all solutions is summarized in Figure 11. 
These solutions were first found by Wiezorke and Haubrich [38], who 
invented the puzzle independently after seeing [1]. 

Polysticks introduce a new feature that is not present in the poly- 
omino and polyiamond problems: The pieces must not cross each other. 



458 Selected Papers on Fun and Games 

For example, Figure 12 shows a non-solution to Barwell’s L-at-the-side 
problem in which every line segment in the grid of 5 x 5 squares is 
covered, but the V tetrastick crosses the Z. 

We can handle this extra complication by generalizing the exact 
cover problem. Instead of requiring all columns of a given 0-1 matrix 
to be covered by disjoint rows, we will distinguish two kinds of columns: 
primary and secondary. The generalized problem asks for a set of rows 
that covers every primary column exactly once and every secondary col- 
umn at most once. 

The tetrastick problem of Figure 11(c) can be set up as a generalized 
cover problem in a natural way. First we introduce primary columns F, 
H, I, J, N, O, P, R, S, U, V, W, X, Y, Z representing the fifteen tetra- 
sticks (excluding L), as well as columns H pq representing the horizontal 
segments (p,q) — (p + l,g) and V qp representing the vertical segments 
(?)P) (Hi Pd~ 1), for 0 < p < 5 and 0 < q < 5. We also need secondary 
columns I pq to represent interior junction points (p, q), for 0 < p, q < 5. 
Each row represents a possible placement of a piece, as in the polyomino 
and polyiamond problems; but if a piece has two consecutive horizon- 
tal or vertical segments and does not lie on the edge of the diagram, it 
should include the corresponding interior junction point as well. 

For example, here are the two rows corresponding to the placement 
of V and Z in Figure 12: 

V H23 133 H33 V43 144 V44 

Z H24 V33 133 V32 H32 

The common interior point 133 means that these rows cross each other. 
On the other hand, 133 is not a primary column, because we do not 
necessarily need to cover it. The solution in Figure 11(c) covers only the 
interior points 114, 121, 132, and 143. 

Fortunately, we can solve the generalized cover problem by using 
almost the same algorithm as before. The only difference is that we 
initialize the data structure by making a circular list of the column 
headers for the primary columns only. Each header node for a secondary 
column should have L and R fields that simply point to the node itself. 
The remainder of the algorithm proceeds exactly as before, so we shall 
still call it algorithm DLX. 

A generalized cover problem can be converted to an equivalent exact 
cover problem of the traditional sort if we simply append one row for 
each secondary column, containing a single 1 in that column. But we are 
better off working with the generalized problem, because the generalized 
algorithm is simpler and faster. 



Dancing Links 



459 


72 solutions, 1,132,070 nodes 382 solutions, 3,422,455 nodes 
283,814,227 updates 783,928,340 updates 



607 solutions, 2,681,188 nodes 


611,043,121 updates 

(d) (e) 



530 solutions, 3,304,039 nodes 204 solutions, 1,779,356 nodes 

760,578,623 updates 425,625,417 updates 


FIGURE 11. Filling a 5 x 5 grid with 15 of the 16 tetrasticks; we must 
leave out either the H, the J, the L, the N, or the Y, as shown. 



Figure 12. Polysticks aren’t supposed to cross each other as they do here. 





460 Selected Papers on Fun and Games 

I decided to experiment with the subset of welded tetrasticks , namely 
those that do not form a simple connected path because they contain 
junction points: F, H, R, T, X, Y. There are ten one-sided, welded 
tetrasticks, if we add the mirror images of the unsymmetrical pieces 
as we did for one-sided hexiamonds and pentominoes. And — aha — 
these ten tetrasticks can be arranged in a 4 x 4 grid. (See Figure 13.) 
Only three solutions are possible, including the two perfectly symmetric 
solutions shown. I’ve decided not to show the third solution, which has 
the X piece in the middle, because I want readers to have the pleasure 
of finding it for themselves. 



Figure 13. Two of the three ways to pack the one-sided welded tetra- 
sticks into a 4 x 4 square. 


There are fifteen one-sided unwelded tetrasticks , and I thought they 
would surely fit into a 5 x 5 grid in a similar way; but this turned out to 
be impossible. The reason is that if, say, piece I is placed vertically, four 
of the six pieces J, J', L, L', N, N' must be placed to favor the horizontal 
direction, and this severely limits the possibilities. In fact, I have been 
unable to pack those fifteen pieces into any simple symmetrical shape; 
my best effort so far is the “oboe” shown in Figure 14. 



Figure 14. The fifteen one-sided unwelded tetrasticks. 


I also tried unsuccessfully to pack all 25 of the one-sided tetrasticks 
into the Aztec diamond pattern of Figure 15; but I see no way to prove 
that a solution is impossible. An exhaustive search seems out of the 
question at the present time. 


Dancing Links 461 


FIGURE 15. Do all 25 of the one-sided 
tetrasticks fit in this shape? 


Applications to Queens 

Now we can return to the problem that led Hitotumatu and Noshita 
to introduce dancing links in the first place, namely the N queens 
problem, because that problem is actually a special case of the gen- 
eralized exact cover problem in the previous section. For example, the 
4 queens problem is just the task of covering eight primary columns 
(R.0, Rl, R2, R3, FO, FI, F2, F3) corresponding to ranks and files, while 
using at most one element in each of the secondary columns (AO, Al, A2, 
A3, A4, A5, A6, BO, Bl, B2, B3, B4, B5, B6) corresponding to diagonals, 
given the following sixteen rows: 


RO FO AO B3 
RO FI Al B4 
RO F2 A2 B5 
RO F3 A3 B6 


Rl FO Al B2 
Rl FI A2 B3 
Rl F2 A3 B4 
Rl F3 A4 B5 


R2 FO A2 Bl 
R2 FI A3 B2 
R2 F2 A4 B3 
R2 F3 A5 B4 


R3 FO A3 BO 
R3 FI A4 Bl 
R3 F2 A5 B2 
R3 F3 A6 B3 


In general, the rows of the 0-1 matrix for the N queens problem are 

Ri F j A (i + j) B(N-l-i + j) 

for 0 < i,j < N. (Here Ri and F j represent ranks and files of a 
chessboard; A k and Bl represent diagonals and reverse diagonals. The 
secondary columns AO, A(2A — 2), BO, and B(2iV — 2) each arise in only 
one row of the matrix so they can be omitted.) 

When we apply algorithm DLX to this generalized cover prob- 
lem, it behaves quite differently from the traditional algorithms for the 
N queens problem, because it sometimes branches on different ways to 
occupy a rank of the chessboard and sometimes on different ways to 
occupy a file. Furthermore, we gain efficiency by paying attention to 
the order in which primary columns of the cover problem are consid- 
ered when those columns all have the same S value (the same branching 
factor): It is better to place queens near the middle of the board first, 
because central positions rule out more possibilities for later placements. 

Consider, for example, the eight queens problem. Figure 16(a) shows 
an empty board, with 8 possible ways to occupy each rank and each file. 


462 Selected Papers on Fun and Games 

Suppose we decide to cover R4 by placing a queen in R4 and F7, as 
shown in Figure 16(b). Then there are five ways to cover F4. After 
choosing R5 and F4 as shown in Figure 16(c), there are four ways to 
cover R3; and so on. At each stage we choose the most constrained rank 
or file, using the “organ-pipe ordering” 

R4 F4 R3 F3 R5 F5 R2 F2 R6 F6 R1 FI R7 F7 RO FO 

to break ties. Placing a queen in R2 and F3 after Figure 16(d) makes 
it impossible to cover F2, so backtracking will occur even though only 
four queens have been tentatively placed. 



88888888 


(b) 



FO 

FI 

F2 

F3 

F4 

F5 

F6 

F7 

R.7 





X 



X 

R6 






X 


X 

R5 







X 

X 

R4 

X 

X 

X 

X 

X 

X 

X 


R3 







X 

X 

R2 






X 


X 

R1 





X 



X 

RO 




X 




X 


7 

7 

7 

6 

5 

5 

5 



f 


(d) 


FO FI F2 F3 F4 F5 F6 F7 FO FI F2 F3 F4 F5 F6 F7 


R7 



X 


X 


X 

X 

4 

R7 


X 

X 


X 

X 

X 

X 

R6 




X 

X 

X 


X 

4 

R6 



X 

X 

X 

X 


X 

R5 

X 

X 

X 

X 

W 

X 

X 

X 


R5 

X 

X 

X 

X 

r? 

X 

X 

X 

R4 

X 

X 

X 

X 

X 

X 

X 

* 


R4 

X 

X 

X 

X 

X 

X 

X 


R3 



X 


X 


X 

X 

4^ 

R3 

X 

X 

X 

X 

X 

w 

X 

X 

R2 


X 



X 

X 


X 

4 

R2 


X 



X 

X 

X 

X 

R1 

X 




X 



X 

5 

R1 

X 



X 

X 

X 


X 

RO 




X 

X 



X 

5 

RO 



X 

X 

X 

X 


X 


5 

5 

4 

4 


4 

4 




4 

3 

2 

2 



3 



t 


Figure 16. Solving the 8 queens problem by treating ranks and files 
symmetrically. 






Dancing Links 463 

Table 3. Behavior of algorithm DLX on the N queens problem 


N 

Solutions 

Nodes 

Updates 

R-Nodes 

R-Updates 

1 

1 

2 

3 

2 

3 

2 

0 

3 

19 

3 

19 

3 

0 

4 

56 

6 

70 

4 

2 

13 

183 

15 

207 

5 

10 

46 

572 

50 

626 

6 

4 

93 

1,497 

115 

1,765 

7 

40 

334 

5,066 

376 

5,516 

8 

92 

1,049 

16,680 

1,223 

18,849 

9 

352 

3,440 

54,818 

4,640 

71,746 

10 

724 

11,578 

198,264 

16,471 

269,605 

11 

2,680 

45,393 

783,140 

67,706 

1,123,572 

12 

14,200 

211,716 

3,594,752 

312,729 

5,173,071 

13 

73,712 

1,046,319 

17,463,157 

1,589,968 

26,071,148 

14 

365,596 

5,474,542 

91,497,926 

8,497,727 

139,174,307 

15 

2,279,184 

31,214,675 

513,013,152 

49,404,260 

800,756,888 

16 

14,772,512 

193,032,021 

3,134,588,055 

308,130,093 

4,952,973,201 

17 

95,815,104 

1,242,589,512 

20,010,116,070 

2,015,702,907 

32,248,234,866 

18 

666,090,624 

8,567,992,237 

141,356,060,389 

13,955,353,609 

221,993,811,321 


The order in which header nodes are linked together at the start of 
algorithm DLX can have a significant effect on the running time. For ex- 
ample, experiments on the 16 queens problem show that the search tree 
has 312,512,659 nodes and requires 5,801,583,739 updates, if the order- 
ing R0 R1 . . . R15 F0 FI ... F15 is used, while the organ-pipe ordering 
R8 F8 R7 F7 R9 F9 . . . R0 F0 requires only about 54% as many updates. 
However, the order in which individual elements of a row or column are 
linked together has no effect on the algorithm’s total running time. 

Table 3 shows some statistics observed when algorithm DLX solved 
small cases of the N queens problem using organ-pipe order, without 
reducing the number of solutions by taking symmetries of the board into 
account. Here “R-Nodes” and “R-Updates” refer to the results when we 
consider only R0, Rl, . . . , R (N — 1) to be primary columns that need to 
be covered; in that case, when columns Fj are secondary, the algorithm 
reduces to the usual procedure in which branching occurs only on ranks 
of the chessboard. The advantage of mixing ranks with files becomes 
evident as N increases, but I’m not sure whether the ratio of R-Updates 
to Updates will be unbounded or approach a limit as N goes to infinity. 

I should point out that special methods are known for counting the 
number of solutions to the N queens problem without actually generat- 
ing the queen placements [34], 


464 Selected Papers on Fun and Games 

Concluding Remarks 

Algorithm DLX, which uses dancing links to implement the “natural” 
algorithm for exact cover problems, is an effective way to enumerate all 
solutions to such problems. On small cases it is nearly as fast as algo- 
rithms that have been tuned to solve particular classes of problems, like 
pentomino packing or the N queens problem, where geometric struc- 
ture can be exploited. On large cases it appears to run even faster than 
those special-purpose algorithms, because of its ordering heuristic. And 
as computers get faster and faster, we are of course tackling larger and 
larger cases all the time. 

In this paper I have used the exact cover problem to illustrate the 
versatility of dancing links, but I could have chosen many other back- 
track applications in which the same ideas apply. For example, the 
approach works nicely with the Waltz filtering algorithm [37]; perhaps 
this fact has subliminally influenced my choice of names. I recently 
used dancing links together with a dictionary of about 600 common 
three-letter words of English to find word squares such as 


ATE 

BED 

OHM 

PEA 

TWO 

WIN 

OAR 

RUE 

URN 

ION 

LED 

WRY 

BET 

BAY 

TEE 


in which each row, column, and left-to-right diagonal is a word; about 
60 million updates produced all solutions. 1 believe that a terpsichorean 
technique is significantly better than the alternative of copying the cur- 
rent state at every level, as considered in the pioneering paper by Har- 
alick and Elliott on constraint satisfaction problems [19]. Certainly the 
use of (1) and (2) is simple, useful, and fun. 

Acknowledgments 

I wish to thank Sol Golomb, Richard Guy, and Gene Freuder for the 
help they generously gave me as I was preparing this paper. Maggie 
McLoughlin did an excellent job of translating my scrawled manuscript 
into a well-organized TgX document. And I profoundly thank Tomas 
Rokicki, who provided the new computer on which I did most of the 
experiments, and on which I hope to keep links dancing merrily for 
many years. 

Historical Notes 

(1) Although the IAS computer was popularly known in Princeton as 
the “MANIAC,” that title properly belonged only to a similar but dif- 
ferent series of computers built at Los Alamos. (See [27].) (2) George 


Dancing Links 465 

Jelliss [23] has discovered that the great puzzle masters H. D. Benjamin 
and T. R. Dawson experimented with the concept of polysticks already 
in 1946-1948. However, they apparently did not publish any of their 
work. (3) My names for the tetrasticks are slightly different from those 
originally proposed by Barwell [3]: I prefer to use the letters J, R, and U 
for the pieces he called U, J, and C, respectively. 

Program Notes 

The implementation of algorithm DLX that I used when preparing this 
paper can be found on the webpage 

http : //www-cs-f acuity . Stanford . edu/~knuth/programs .html 

as file dance, w, with the related files polyominoes . w, polyiamonds .w, 
polysticks .w, and queens. w. 

References 

[1] 845 Combinations Puzzles: 845 Interestingly Combinations (Tai- 
wan: R.O.C. Patent 66009). [There is no indication of the author 
or manufacturer. This puzzle actually has only 83 solutions. It 
carries a Chinese title, ; ‘Dr. Dragon’s Intelligence Profit System.”] 

[2] Harry Barris, Mississippi Mud (New York: Shapiro, Bernstein & 
Co., 1927). 

[3] Brian R. Barwell, “Polysticks,” Journal of Recreational Mathemat- 
ics 22 (1990), 165-175. 

[4] Elwyn R. Berlekamp, John H. Conway, and Richard K. Guy, Win- 
ning Ways for Your Mathematical Plays 2 (London: Academic 
Press, 1982). [In the second edition (Wellesley, Massachusetts: A I< 
Peters, 2004), volume 4, the hexiamond puzzle is discussed on pages 
895-896 and 920.] 

[5] Max Black, Critical Thinking (Englewood Cliffs, New Jersey: 
Prentice-Hall, 1946). 

[6] Ole-Johan Dahl, Edsger W. Dijkstra, and C. A. R. Hoare, Struc- 
tured Programming (London: Academic Press, 1972). 

[7] N. G. de Bruijn, personal communication (9 September 1999): “. . . 
it was almost my first activity in programming that I got all 2339 
solutions of the 6 x 10 pentomino on an IBM 1620 in March 1963 in 
18 hours. It had to cope with the limited memory of that machine, 
and there was not the slightest possibility to store the full matrix 


466 Selected Papers on Fun and Games 

• . . But I could speed the matter up by having a very long program, 
and that one was generated by means of another program.” 

[8] N. G. de Bruijn, “Programmeren van de pentomino puzzle,” Eu- 
clides 47 (1971/72), 90-104. 

[9] Henry Ernest Dudeney, “74. — The broken chessboard,” in The Can- 
terbury Puzzles (London: William Heinemann, 1907), 90- 92, 174- 
175. 

[10] John G. Fletcher, “A program to solve the pentomino problem by 
the recursive use of macros,” Communications of the ACM 8 (1965), 
621-623. 

[11] Robert W. Floyd, “Nondeterministic algorithms,” Journal of the 
Association for Computing Machinery 14 (1967), 636-644. 

[12] Martin Gardner, “Mathematical games: More about complex domi- 
noes, plus the answers to last month’s puzzles,” Scientific American 
197,6 (December 1957), 126-140. 

[13] Michael R. Garey and David S. Johnson, Computers and In- 
tractability (San Francisco: Freeman, 1979). 

[14] S. W. Golomb, “Checker boards and polyominoes,” American 
Mathematical Monthly 61 (1954), 675-682. 

[15] Solomon W. Golomb, Polyominoes , second edition (Princeton, New 
Jersey: Princeton University Press, 1994). 

[16] Solomon W. Golomb and Leonard D. Baumert, “Backtrack pro- 
gramming,” Journal of the Association for Computing Machinery 
12 (1965), 516-524. 

[17] Richard K. Guy, “Some mathematical recreations,” Nabla (Bulletin 
of the Malayan Mathematical Society) 7 (1960), 97-106, 144-153. 

[18] Richard K. Guy, “O’Beirne’s Hexiamond,” in The Mathemagician 
and Pied Puzzler, edited by Elwyn Berlekamp and Tom Rodgers 
(Natick, Massachusetts: A K Peters, 1999), 85-96. 

[19] Robert M. Haralick and Gordon L. Elliott, “Increasing tree search 
efficiency for constraint satisfaction problems,” Artificial Intelli- 
gence 14 (1980), 263-313. 

[20] Jenifer Haselgrove, “Packing a square with Y-pentominoes,” Jour- 
nal of Recreational Mathematics 7 (1974), 229. 

[21] C. B. Haselgrove and Jenifer Haselgrove, “A computer program 
for pentominoes,” Eureka: The Archimedeans ’ Journal 23 (1960), 
16-18. 


Dancing Links 467 


[22] Hirosi Hitotumatu and Kohei Noshita, “A technique for implement- 
ing backtrack algorithms and its application,” Information Process- 
ing Letters 8 (1979), 174-175. 

[23] George P. Jelliss, “Unwelded polysticks,” Journal of Recreational 
Mathematics 29 (1998), 140-142. 

[24] Donald E. Knuth, “Estimating the efficiency of backtrack pro- 
grams,” Mathematics of Computation 29 (1975), 121-136. [Re- 
printed as Chapter 6 of Selected Papers on Analysis of Algorithms , 
CSLI Lecture Notes 102 (Stanford, California: Center for the Study 
of Language and Information, 2000), 55-75.] 

[25] Donald E. Knuth, TpjK: The Program, Volume B of Computers <fc 
Typesetting (Reading, Massachusetts: Addison- Wesley, 1986). 

[26] .Jean Meeus, “Some polyomino and polyamond problems,” Journal 
of Recreational Mathematics 6 (1973), 215-220. 

[27] N. Metropolis and J. Worlton, “A trilogy of errors in the history of 
computing,” Annals of the History of Computing 2 (1980), 49-59. 

[28] T. H. O’Beirne, “Puzzles and Paradoxes 43: Pell’s equation in two 
popular problems,” New Scientist 12 (1961), 260-261. 

[29] T. H. O’Beirne, “Puzzles and Paradoxes 44: Pentominoes and hex- 
iamonds,” New Scientist 12 (1961), 316-317. [“So far as we know, 
hexiamond lias not yet been put through the mill on a computer: 
but this could doubtless be done.”] 

[30] T. H. O’Beirne, “Puzzles and Paradoxes 45: Some hexiamond solu- 
tions: and an introduction to a set of 25 remarkable points,” New 
Scientist 12 (1961), 379-380. 

[31] Marc Paulhus, “Hexiamond Homepage,” a collection of webpages 
once at http://www.math.ucalgary.ca/~paulhusm/hexiamondl. 
The version of 20 April 1999 is accessible from The Internet Archive. 

[32] Christoph Peter-Orth, “All solutions of the Soma Cube puzzle,” 
Discrete Mathematics 57 (1985), 105-121. 

[33] J. E. Reeve and .1. A. Tyrrell, “Maestro puzzles,” The Mathematical 
Gazette 45 (1961), 97-99. 

[34] Igor Rivin, Han Vardi, and Paul Zimmermann, “The n-queens prob- 
lem,” American Mathematical Monthly 101 (1994), 629-639. 

[35] Dana S. Scott, “Programming a combinatorial puzzle,” Technical 
Report No. 1 (Princeton, New Jersey: Princeton University Depart- 
ment of Electrical Engineering, 10 June 1958), ii + 14 + 5 pages. 


468 Selected Papers on Fun and Games 

[From page 10: . . the main problem in the program was to handle 

several lists of indices that were continually being modified.”] 

[36] P. J. Torbijn, “Polyiamonds,” Journal of Recreational Mathematics 
2 (1969), 216-227. 

[37] David Waltz, “Understanding line drawings of scenes with shad- 
ows,” in The Psychology of Computer Vision, edited by P. Winston 
(New York: McGraw Hill, 1975), 19-91. 

[38] Bernhard Wiezorke and Jacques Haubrich, “Dr. Dragon’s poly- 
cons,” Cubism For Fun 33 (February 1994), 6-7. 

Addendum 

After seeing this paper in print, I realized that algorithm DLX never 
changes the L and R links, except in the column objects. Therefore 
the data objects for row entries can be stored sequentially, and they 
need contain only three links (not live). Dummy objects, containing two 
links each, can be placed between rows so that the cyclic traversal of 
row elements is still efficient in either direction. 

Ten more years of continued progress in computer hardware have 
allowed the links inside my desktop machine to dance faster than ever: 
The 1.2 GHz Intel “Core 2 Duo CPU” that I acquired in 2007 now 
performs nearly 50 million DLX-type updates per second! And with 
both processors working on different subproblems, I get more than 90 
mega-updates/sec. Thus it’s easy nowadays for me to try computations 
for which I didn’t have enough patience in 1999. 

I don’t know what I was thinking when I estimated the difficulty 
of the 9 x 10 one-sided pentomino problem of Figure 10. I blundered 
badly when 1 claimed that the method of [24] gives an estimate of 19 
quadrillion updates. When I rerun the calculations today, using [24] 
properly, I consistently obtain predictions of a much smaller problem 
size, between 3 and 5 trillion updates only. 

I received letters early in 2000 from Alfred Wassermann and from 
Pat.ric Ostergard, who both had been able to resolve this problem com- 
pletely and to discover that it has exactly 10,440,433 solutions. (See 
Alfred Wassermann, “One-sided pentominoes in a 9 x 10 rectangle,” 
http : //did . mat . uni-bayreuth . de/wassermann/pentominoes . ps . gz. 
a preprint dated 26 May 2000.) In fact, the spiffy computer I now have 
at home allows me to report that algorithm DLX confirms the number of 
solutions that they found, after exploring a search tree of 14,077,934,683 


Dancing Links 469 



Figure 17. Improvements to Figure 10. 

nodes and making 4,627,081,954,873 updates. Thus the problem is in- 
deed more difficult, than O’Beirne’s hexiamond problem of Figure 8 — 
but only by a factor of 35, not by a factor of 140,000. 

This exhaustive enumeration turns up several solutions that are 
much more symmetric than I had thought possible. The grand cham- 
pion for symmetry, shown in Figure 17(a), has an amazingly high vertical 
score, vsym = 83: When this pattern is flipped top-to-bottom, 83 of its 
87 internal edges remain unchanged, and in fact 14 of its 18 pieces re- 
main fixed. The horizontal score, hsym = 60, is quite respectable too. 
And Figure 17(b) shows that my attempt to obtain maximum horizon- 
tal symmetry in Figure 10 wasn’t optimum either — even though Fig. 10 
had 10 pieces fixed by horizontal reflection while Fig. 17(b) has only 8. 

The other question that I was unable to answer when I presented my 
paper in 1999 has also led to happy results: The 25 one-sided tet.rasticks 




470 Selected Papers on Fun and Games 

can, in fact, be packed into the Aztec diamond shape of Figure 15, 
thereby fulfilling my fondest hopes. Alfred Wassermann used a cluster 
of 16 workstations in November 1999 to discover that there are exactly 
107 ways to accomplish this feat. [See “Covering the Aztec diamond 
with one-sided tet.rasticks, Bulletin of the Institute of Combinatorics 
and its Applications 32 (2001), 70-76.] 

Several of these intricate and elusive patterns are especially striking. 
For example, 9 of the 25 pieces in 



remain unchanged under left-right reflection. And in 



there are actually 10 such symmetrical pieces. Wassermann depicts them 
all, in color, in his online document http://did.mat.uni-bayreuth.de/ 
wassermann/ allsolutions . pdf. 


Dancing Links 471 

Algorithm DLX solves this task by considering six inequivalent 
placements of the X, and by restricting the I to be vertical in two of 
those six cases. The computation turns out to involve 12,318,463,410,037 
updates, for search trees of 33,831,460,543 nodes all told. 

Some people have questioned whether I should have called this shape 
an “Aztec diamond,” because many papers about Aztec diamonds re- 
strict consideration to cases where there are two cells at the top, bottom, 
left, and right. My terminology, however, is based on Richard Stanley’s 
more flexible definition, according to which the shape of my Figure 15 
is the Aztec diamond of order 9/2. In general, an Aztec diamond of 
order s has 2s rows, 2s columns, and staircase-like boundaries. In a 
(2k + 1) x (2k + 1) checkerboard with black squares at the corners, the 
set of white squares is essentially equivalent (after 45° rotation) to an 
Aztec diamond of order k, while the set of black squares is essentially 
equivalent to an Aztec diamond of order k + \ . (See my paper “Aztec 
diamonds, checkerboard graphs, and spanning trees,” Journal of Alge- 
braic Combinatorics 6 (1997), 253-257, reprinted as Chapter 10 of my 
Selected Papers on Discrete Mathematics, for further discussion and 
generalization to “Aztec rhomboids.”) 

Let me close this chapter by exhibiting another pleasant polystick 
pattern, inspired by a question of Brian Barwell in the Journal of Recre- 
ational Mathematics 35 (2006), page 68: 



Here the “monostick,” the two “disticks,” and the five “tristicks” (in 
black) are mixed with the sixteen tetrasticks (in white), all two-sided, 
in such a way that the eight black polysticks all appear in the top half, 


472 Selected Papers on Fun and Games 

without touching each other. (This problem has 37 solutions; the reader 
is encouraged to find them all. According to [23], H. D. Benjamin was 
apparently the first to discover that these 24 polysticks could be packed 
into a square array, on 6 October 1948.) 


Chapter 39 


Nikoli Puzzle Favors 


[Dedicated to the memory of Nob Yoshigahara. Presented at the 
Twenty-Ninth International Puzzle Party (IPP29), San Francisco, Cal- 
ifornia, in August 2009.] 

1. Masyu 

Nikoli Co., Ltd., has been publishing wonderful pencil-and-paper puzzles 
since 1980. Some of them, like Sudoku, are based on combinatorics 
and logic; others are based on pure geometry and involve no numbers 
whatsoever. Masyu (“evil influence”) is one of the best of the latter type. 

The idea is to draw a closed loop of straight segments through the 
centers of grid cells, in such a way that (a) the path turns 90° at each 
cell that is marked with a black stone, but goes straight through the 
two neighboring cells; (b) the path goes straight through each cell that 
is marked with a white stone, but turns 90° at one or both of the two 
neighboring cells. The path must not cross itself. For example, 


forces the loop-path to be 




the setup 




o 




• 









o 


o 

o 








473 





474 Selected Papers on Fun and Games 

2. Slitherlink and Skimperlink 

Slitherlink is another Nikoli puzzle based on loops, but this time the loop 
is supposed to run through corners of the cells instead of the midpoints. 
When a number is placed in a cell, exactly that many of the cell’s edges 
must belong to the loop. A new variant that I call “skimperlink” is sim- 
ilar, except that more than one loop is allowed; the goal of skimperlink 
is to use the fewest edges, not the fewest loops. For example, 


the setup 


.3. 

•p°- slither links to 

3j 

1 * 0 

1 'l' 

X . 

, 2 1 


: tm : 

but skimper links to • • A.°. . 

: CJO 

Notice that each loop with k edges touches exactly k points of the grid; 
thus, the skimperlink problem is the same as asking for a set of disjoint 
loops that satisfy the numeric constraints and touch the fewest points. 
Solve the following skimperlink: 


2; '23' 12 21 ' '2' I'l l' 

2 2. 01 222 0 

0 1121 12 12 ' ' 12 ' 

01 0 1 

... 1 0 

.1. .0. . . 1' 1 ' 

0. .1. . . . 01 0 2 0 

..11 11 'o'o' 

1 '1 

0 10 1 O' ' 2 

2.1. 1 2 ' 'O' 0 1 10' 

2. . .3. , .2 2 ' '3" ' '21' ' 12 ' ' 


2 2 ' 

0.1 0 1 1201 
2 1 ' 

f O' 'l' ' ' 2 

1 ' ' ' l'O 

0 12 

111 O ' ' 'l 

11 2 O'O' l' 

. 1 . 1 , . 0 . 0 . 1 . ' 2.2 

1 ' ' 1 ' O ' l ' 

2.:. 1.2; ; ; ;i;t2 


2 2 ' 12 1 ' 

2 '2 'll' 12 

12 0 ' ' '2 '0 

0 13 1 12 11 ' O ' 

2. . 2 1 0 2 1 

2 1 ' '2 

2 2 1 O' 

11'' 02 
1 ' 112' 

2311222 ' 220 

1 2 ' '2 2 

1 2 2 2 2 1'' '22 


Nikoli Puzzle Favors 475 


3. Solutions 

Before I give the answers to those puzzles, I want to mention that both 
masyu and slitherlink are excellent examples of problems for which com- 
puter structures called BDDs and ZDDs work wonders. [See The Art of 
Computer Programming, Volume 4A (Addison- Wesley, 2010), Section 
7.1.4, for a comprehensive introduction to BDD and ZDD technology.] 

Suppose the horizontal edge that extends rightward from point (i, j) 
is denoted by hij. We let hij = 1 if that edge is present, otherwise 
hij = 0. Similarly, we suppose that v ZJ represents the vertical edge that 
extends downward from (*, j), where v l3 = 1 or v tJ = 0. The condition 
that a choice of edges for skimperlink makes proper loops is that every 
point is touched by exactly zero or two edges; that is, 

hij + Vij + hi(j_ i) + = 0 or 2 (*) 

for all points ( i,j ). (When a point is on the boundary, this equation 
refers to missing edges outside the diagram, which are always zero.) 
The further condition that a cell with point ( i,j ) in its upper left corner 
is surrounded by exactly dij edges is 

hij + + /i(j +1 )j + Vi(j + 1) = dij , (**) 

whenever dij has been specified. 

The given skimperlink puzzle has 1312 edge variables (676 h’ s and 
636 As), so the number of possible ways to set them each to 0 or 1 
is huge: 2 1312 = 89,403,456,790,138,199,504,722,663,845,938,162, 
546, 598, 192, 956, 947, 925, 057, 063, 268, 777, 466, 378, 033, 398, 197, 844, 
774, 764, 419, 923, 259, 919, 936, 119, 490, 754, 348, 335, 315, 827, 215, 256, 
797, 393, 219, 729, 086, 127, 756, 921, 211, 321, 811, 144, 190, 452, 640, 067, 
268, 641, 216, 468, 033, 705, 852, 087, 174, 876, 295, 013, 276, 952, 237, 406, 
566, 616, 302, 156, 609, 034, 102, 568, 251, 715, 295, 346, 981, 084, 737, 525, 
424, 640, 722, 115, 940, 281, 297, 509, 188, 186, 649, 324, 815, 686, 699, 212, 
604, 140, 246, 556, 947, 662, 422, 743, 704, 115, 482, 557, 772, 626, 648, 955, 
221,254,191,950,005,687,812,096 « 8.9 x 10 394 . But the ZDD for all 
these solutions is very simple; it has only 1313 nodes. Then we can 
easily incorporate all the conditions of (*) and (**), ordering the edge 
variables lexicographically on ( j , i) and getting a ZDD of 299,244 nodes 
that describes all ways to choose legal edge combinations. The number of 
such combinations is 458, 524, 440, 120, 243, 839, 648, 854, 802, 389, 756, 
214,626,867,672,178,768 m 4.6 x 10 5 ° — still huge, but not nearly so 
vast as before. Moreover, the calculation of this ZDD goes very quickly, 
considering that 1312 variables are being handled: Less than two billion 


476 Selected Papers on Fun and Games 

memory accesses are needed, and about 51 megabytes of memory. There- 
fore a run-of-the-mill laptop, vintage 2007, finds it in about 36 seconds. 

And here comes the punch line: The skimperlink solution — namely, 
the solution with fewest edges, from all those 4.6 x 10 J ® possibilities — is 
easy to “read off' from the ZDD, in less than one second of further calcu- 
lation, including the time to verify that the minimum solution is unique. 

A similar approach works for the given masyu problem. Instead of 
(**), we use the conditions 

hij + Vij + = 2 

hijVij + + wp-i )jhij = 1 

hijhi(j+ 1 ) = v ijV(i + l)j = hi(j_i)hi(j_ 2 ) = = 0 

when point (i,j) is specified black (here x stands for 1 — x), or 

hzj + Vij + i) + = 2 

h-ij = hi(j_ip Vij = 

when point (i, j) is specified white. The ZDD in this case turns out to 
have just 253 nodes; it can be computed in about one second (more pre- 
cisely, after 56 million accesses to 10.5 megabytes of memory). Another 
fraction of a second establishes the fact that the constraints of problem 1 
are satisfied by exactly 400 of the 2 352 possible ways to choose the edges, 
and that exactly one of those 400 defines a single loop. 




(The masyu is easily solved by hand, but I suspect that the giant skim- 
perlink problem will be much harder for mere mortals to psych out.) 





Chapter 40 


Uncrossed Knight’s Tours 

[Originally published in the Journal of Recreational Mathematics 2 
(1969), 155-157, as a letter to the editor.] 

Mr. Yarbrough’s uncrossed knight’s tours [1], which maximize knight 
moves that don’t intersect, are a pleasant recreation. Not being too 
good at it by myself, however, I programmed it for our computer. 

Well over three billion cases were examined — without getting into 
any 7 x 9, 8 x 9, or 9 x 9 boards (too big for the machine!). The findings 
are summarized in Figures 1 and 2, which show respectively the longest 
possible uncrossed paths and the longest possible uncrossed cycles, on 
various rectangular boards. 

These machine runs confirmed that Yarbrough’s path of length 35 
on the ordinary 8x8 chessboard is indeed maximum, as are most of his 
examples on smaller boards. But improved paths for the 6 x 6, 6 x 8, 
and 7x8 boards have been found by others [2, 3]. My computations of 
the absolutely longest tours were able to beat the hand-crafted solutions 
of those authors only in one case, 5 x 6 — which is a rather small board, 
not big enough to be considered much of a challenge. The new path of 
length 14 on this board is surprisingly long, when we compare it to the 
best possible results on 5 X n boards for n near 6, as well as to the best 
possible results on 6 x n boards for n near 5. 

My programs also were able to find maximum-length cycles in every 
case up to 8 x 8; Yarbrough’s paper exhibits cycles only on the 3x6 and 
7x7 boards. Long cycles are harder to find than long paths. 

Several interesting general properties of uncrossed knight’s tours 
were also discovered during this study. For example, variants of the 
maximal 5x8 path 



will yield paths of length 6n — 5 on any 5 x 2n board with n > 2. 


477 



8 


9 


478 Selected Papers on Fun and Games 


3 4 5 


6 


7 


M M MS BSS t#HMS 


2(2) 4(1) 5(1) 6(2) 8(1) 

4 


9(1) 10(1) 








5(5) 7(14) 9(18) 11(18) 13(22) 15(29) 












10(4) 14(1) 16(7) 19(7) 


22(4) 





V As 

' L 





I 

"'I Ip 


17(1) 21(3) 25(1) 





24(13) 30(1) 


35(1) 


Figure 1 . Uncrossed knight paths 
of maximum length on rectangular 
boards. The length is followed in 
parentheses by the number of differ- 
ent ways to achieve it. Thus, ‘(l)’ 
indicates a path that is uniquely 
optimum for its board size. (Some 
of the results for large boards were 
not known until 2008; see below.) 



ft 

, U Jr 








47(3) 


It is easy to show that the longest cycles on a 3 x n board are 
essentially the same for n = 4k + 2, 4k + 3, 4k + 4, and 4k + 5 when 
k>\. They will have length 4k + 2, with the general form indicated in 
Figure 3. Likewise, the longest cycles on 4 x n boards have length 2n - 4 
for n > 4, but in this case the solutions are not always unique. 



Uncrossed Knight’s Tours 479 


3 4 5 


0(1) 0(1) 4(1) 6(1) 


ggg gggg gg§): 

6 ( 1 ) 6 ( 2 ) 6 ( 2 ) 


B 





4(2) 6(1) 8(1) 10(8) 12(1) 


14(1) 







S (6) 12(2) 14(5) 18(1) 


20(1) 










-f 

-t- 

& 

a 


n 


y 



12(51) 18(12) 22(3) 





24(1) 26(21) 32(1) 


FIGURE 2. Uncrossed knight cycles 
of maximum length on rectangular 
boards. The length is followed in 
parentheses by the number of differ- 
ent ways to achieve it. 





42(15) 


Figure 3. Optimum uncrossed 
knight cycles on 3 X n boards, 
when 4k + 2 < n < 4k + 5. 



480 Selected Papers on Fun and Games 


An uncrossed cycle of length n 2 - 8n + 12 is possible on any n X n 
board when n is a multiple of 4 and n > 8. Figure 4 illustrates this 
construction for n = 16, with a cycle of length 140. 



Figure 4. A general way 
to achieve asymptotically 
optimum density. 


References 

[1] L. D. Yarbrough, “Uncrossed Knight’s tours,” Journal of Recre- 
ational Mathematics 1 (1968), 140-142. 

[2] Ronald E. Ruemmler, “Uncrossed Knight’s tours” (letter to the 
editor), Journal of Recreational Mathematics 2 (1969), 154 -157. 

[3] Michio Matsuda and S. Kobayashi, “Uncrossed Knight’s tours” (let- 
ter to the editor), Journal of Recreational Mathematics 2 (1969), 
155 157. 

Addendum 

The word “tour is used somewhat loosely when crossing is forbidden, 
because ordinary knight’s tours are supposed to visit every square of the 
chessboard. Here we are mainly thinking about paths or cycles that are 
as long as possible; it’s probably best to call them just paths and cycles, 
because we don’t have proofs of optimality except on small boards. 

I investigated these fascinating tours/paths/cycles in 1968 and 1969 
during my year of national service at the Institute for Defense Analyses 
in Princeton, New Jersey. As part of that job I had access to a CDC 
6600 computer, which was the world’s fastest machine at the time. 

I used standard “backtracking” techniques to enumerate the tours 
exhaustively, and it turned out to be quite a huge calculation. The 5x5 
case needed only 0.8 seconds to run, but my program took 11.2 seconds 
to study the 6x6 board and 23.0 minutes to do the 7x7. At that rate, 
the 8x8 would have needed more than 400 hours, according to an estima- 
tion procedure that I was developing [see Donald E. Knuth, “Estimating 
the efficiency of backtrack programs,” Mathematics of Computation 29 
(1975), 121-136; reprinted as Chapter 6 of Selected Papers on Analysis 



Uncrossed Knight’s Tours 481 


FIGURE 5. An extension of Figure 2, made 
possible by recently invented ZDD technology. 


10 


SSSB 


of Algorithms, CSL1 Lecture Notes 102 (Stanford, 
California: Center for the Study of Language and 
Information, 2000), 55-75]. So I rewrote the pro- 
gram in assembly language, and wound up with a 
total running time of 117 hours to analyze the 8x8 
board — not counting the hours that I devoted to 
writing the code and debugging it. 

I worked things out so that the computer would 
run this job only during idle time, in the “back- 
ground,” when there was no other work to do. Spe- 
cial procedures for restarting and for recovery from 
machine failures were needed, because several weeks 
went by before the run was finished. Still, com- 
puters were extremely expensive in 1969, especially 
when machines of this caliber were concerned; the 
cost of 117 hours on a CDC 6600 at commercial 
rates in those days might have exceeded a million 
dollars! Therefore my employers suggested that it 
could be unwise to publicize the fact that so much 
“virtual government money” was being spent on a 
chessboard recreation - even though the related re- 
search on backtracking eventually turned out to be 
quite valuable — and I agreed to keep quiet about 
the running time details. This arrangement worked 
out nicely for me, because people were amazed that 
I could solve such a problem with a reasonable cost; 
in fact, I couldn’t, but I wasn’t supposed to admit it. 

The 7x9 problem is harder than the 8x8, 
because it has less symmetry. And boards that were 
even larger were clearly out of the question in 1969. 
But I happened to discover a new way to deal with 
paths and cycles in 2008, by using so-called ZDD 
structures instead of backtracking. Therefore I’m 
now able to complete the study of the 7 x 9, 8 x 9, 
and 9x9 boards, thereby filling in several entries 
that were necessarily missing from Figures 1 and 2 
when my letter was originally published. In fact, 
I now can also present complete information about 


10 ( 1 ) 



54(78) 



482 Selected Papers on Fun and Games 

the uncrossed knight cycles on all boards up to size 10 x 10 (see Figure 5); 
cycles turn out to be easier than paths, ZDD-wise. 

Some board sizes in Figures 1 and 2 have many different optimal 
solutions; for example, there are 14 ways to fit an uncrossed path of 
length 7 into a 4 X 5 board. (In fact it’s fun to find them all by hand, 
because they’re quite pretty and can be used as design motifs. A com- 
plete list appears at the end of this chapter.) But in other cases there’s 
only one way to achieve the maximal length; this happens when an un- 
usually long path or cycle turns out to exist. Thus, for example, the 
paths of length 30 and 42 on the 7x8 and 8x9 boards are longer than 
normal, hence difficult to find. How on earth did Ruemmler [2] discover 
them by hand? Readers who enjoy a challenge might like to find an 
uncrossed knight path of length 43 in a 5 x 16 board. There are only 
two ways to do it. (Hint: Both solutions are symmetric under rotation 
by 180°.) The answers appear below. 

When several different solutions exist, I chose a representative one 
to display in Figure 1 or Figure 2 by always showing a solution with 
maximum symmetry; and if several solutions have maximum symmetry, 
I chose an “unusual” instance, in order to illustrate as much variety 
as possible. Solutions that aren’t strictly the same often turn out to 
be very close to each other; for example, the four length-35 uncrossed 
knight paths on the 8x8 chessboard are 



and it’s easy to see that the first two differ in only two edges near the 
center; the other two differ only in four edges at the lower right corner. 
Similarly, the three paths of length 47 on the 9x9 chessboard are 











the latter two differ only in their final step at one endpoint. I put the 
first of these three into Figure 1, because the middle solution had already 
been published by Ruemmler, Matsuda, and Kobayashi [2,3], 

The ZDD technique that I used for these new results is based on 
the method described in exercises 7.1.4-225 and 7.1.4-226 of The Art of 



Uncrossed Knight’s Tours 483 


Computer Programming; those exercises describe how to represent all 
of the simple paths and simple cycles of an undirected graph in terms of 
a binary branching structure. I extended that method to forbid edges 
that cross each other, using an idea that Dan Eilers had described to me 
in 2000: We can introduce “dummy vertices” into the graph, eight per 
cell, analogous to the secondary columns for interior junction points of 
the tetrastick problems that I had considered in my paper on dancing 
links. Each knight move can be thought of as passing not only from one 
cell of the chessboard graph to another, but also as passing through (or 
near) four of the dummy vertices, as indicated in the following diagram: 



If no dummy vertex is encountered twice, no edges cross. 

With this procedure I was able to represent all of the 10 X 10 un- 
crossed knight cycles inside the computer as a single ZDD structure, 
namely as a directed acyclic graph consisting of 50,160,557 two-way 
branch nodes and two sink nodes. Each of those branch nodes essen- 
tially asks whether or not to include a particular knight move as part 
of the tour. One of them is called the root; every path from the root to 
the “positive” sink corresponds to an uncrossed knight cycle. The total 
number of such paths, which is also the total number of uncrossed knight 
cycles (without taking any symmetries into account), is easily deduced 
from the ZDD, and it turns out to be exactly 5,534,720,777,802. 

Thus I could study all 5.5 trillion of the 10 x 10 cycles without ex- 
amining them one by one. In fact, the total computer time that I needed 
for this task came to about 220 minutes, so this ZDD approach was able 
to deal with roughly 419 million knight cycles per second. That’s fewer 
than 7.2 machine-clock cycles per knight cycle! 

Similarly, the uncrossed 9x9 knight paths can be represented as a 
sequence of 14 ZDDs, one for each of the inequivalent starting points of 
paths that end at a point not equivalent to a previous start. (First we 
try to start at a corner and end anywhere; then we try to start next to a 
corner and end at any noncorner; and so on.) These 14 ZDDs turn out 
to have about 386 million nodes altogether. 

I should point out that this ZDD-based approach does require several 
gigabytes of memory. It would not have been feasible in 1969. 

There may be a way to treat 11 x 11 cycles and 10 x 10 paths by 
generalizing these methods to two-sided ZDDs (where one ZDD starts 
at the top of the board and another starts at the bottom). And after 



484 Selected Papers on Fun and Gaines 

a few more years of Moore’s law I can imagine going up to 12 X 12 
boards, maybe even 13 X 13. But at present i see no way to carry out an 
exhaustive study of all possible 16 x 16 uncrossed knight cycles or paths. 

The history of uncrossed knight’s tours actually goes back to 1930, 
when the great puzzlist Thomas Rayner Dawson presented the prob- 
lem of finding an uncrossed knight path of length 35 on an ordinary 
chessboard, as well as an uncrossed knight cycle of length 32. [T. R. 
Dawson, “Les echecs feeriques, §43- Lignes et points du quadrillage: 
Les Circuits de Sauteurs,” problem 186, L'Echiquier (2) 2 (1930), 1085.] 
He presented two solutions [L'Echiquier (2) 3 (1931), 1150], namely the 
second and third of the four 35-step paths shown above, together with 
a 32-cycle that was found by his Romanian friend Wolfgang Pauly. 

Major advances in the theory were made in France by Jean Cornue- 
jols and Bernard Lemaire [see P. Berloquin, “Jeux et paradoxes,” Science 
et Vie 119,640 (January 1971), 138-139; 641 (February 1971). 128-129; 
126,684 (September 1974), 122 123] and independently in England by 
Robin Merson [see Games & Puzzles 9 (January 1973), 27], In par- 
ticular, they all found efficient ways to extend paths when the board 
size increases by 8. Lemaire and Merson continued to make substan- 
tial improvements during their spare time during the 70s and 80s, but 
without publishing their results - - and indeed remaining unaware of each 
other’s existence. Finally it became known that uncrossed knight paths 
of length at least n 2 — 6n + 21 are possible on all n x n boards for 
n > 10, and that this lower bound can often be improved by 2. Lemaire 
has even improved it by 3, whenever n mod 8=1. Alexander Fischer 
was the first to publish tours of length 135 and 183 on the 14 x 14 and 
16 x 16 boards [ The Games and Puzzles Journal #45 (September 2006), 
§1]. Merson also discovered how to construct the best- known uncrossed 
knight cycles, of length at least n 2 - 7n + 24 on n x n boards when 
7 < n < 32, and at least n 2 — 7 n + 22 when n > 32. Here, for example, 
are Fischer’s length-183 path and Merson’s lengtli-172 cycle for n = 16: 





Uncrossed Knight's Tours 485 

The paper “Non-intersecting paths by leapers” in The Games and 
Puzzles Journal 2, #17 (October 1999), 305-310, by Robin Merson and 
George Jelliss, summarizes Merson’s results and also discusses the un- 
crossed tours that can be made by generalized knights called leapers. 

While composing this addendum in 2010, I suddenly realized that 
there was a whole class of uncrossed knight tour problems still waiting 
to be investigated: We can work with “wraparound” chessboards (also 
known as toruses), where the knight is allowed to exit through the top, 
bottom, left, or right boundary of the board and come in at the other 
side, as long as it doesn’t cross another part of its path. In essence, 
we allow the knight to “think outside the box,” provided that its path 
doesn’t intersect any other paths that could be obtained by replication 
in an infinite tiling of the plane. For example, the 10-cycle 



is noncrossing on a 3 x 5 torus, because the corresponding infinite tiling 
looks like this: 



IRS 

■Fit 

IE* 

m 



If; 

ini 

1E1 

mmm 

*31 

IK! 

SPf 

IF 

■PVI 

IE 


IF 

■Ml 

IE1 

191 

■ ai 

■31 

IK! 


r 

pp* w 

IC1 

to 

■J 

ft: 

IK1 

i* 

IK 

<#. 

ti 

51 

MR 


<r#.i 

Pt: 

mi 

■K' 


<51 

to 

*»L9I 

^<#.1 

Pt: 

mi 

■ML 

Sr 

r 71 
t: 

mi 

■ML 

■m?. 

W* ig 

rffS 

<51 

INI 

Ill 

k>2l 

^71 

'^i* 

mi 

ib«f r 

Sft 

M 

■■ 


ISM 

Hi 

it 

w. 

ft 

m 

\%» 


ISM 

■il 

5' 

If! 

.41 

4W“. 

w *an 

■R* 

i «i 

M 

5? 


IRS 

Ml 

ini 

r*: 

«4I 

N«S 


IKS 

ISM 

IMI 

it: 

If 

ft 

IP m 

»\ 

i# 

MWi 

t 

Si 

PBS 

to 

Pt: 


ft 

<51 

to 

flit 

Ml 

■ML 

* 

Wl 

t: 

■ML 

ft 

W’i 

;5« 

mv 

to 


»V 

Sft 

■v 

it 

IP 


P9! 

1 9ft 

TMm 



IE?* 

ISM 

Ml 

9* 

ftP! 

>«s 

ifti 

■E> 

ISM 

M 

c 

91 

■R* 

ISM 

Ml 

mi 

Pf! 

\t! 

S9J 

IKS 

ISM 

IMI 

it: 

*r 

pt 

ft: 

!«\ 

IKi 

IE* 

51 

91 

to 

"ji 

Pt: 

»t 

5F, 

ft 

<51 

to 

sn 


ns 

JL 

t: 


ft 

<51 

to 

'sll 


«V 

Ifi 

ift 

ILl 

;; 

i" 


Cycles on a torus might not return to their starting point when we 
draw them outside the box; they might end up on another tile in the 
plane. In that case an infinite path is traced out in the plane as we 
traverse the cycle repeatedly — and that path becomes doubly infinite if 
we follow the cycle in both directions. Such doubly infinite paths will 
fill the plane, without crossing, if we replicate them; but I decided to re- 
strict attention to cases where the cycle forms a closed polygon, because 
those shapes are much more interesting. (For example, a knight that 
continually travels in the same direction will make a cycle of length 15 
on a 3 x 5 torus, thus covering every cell. But that’s no big deal, because 
the corresponding infinite path is simply a straight line. Very boring.) 
The only noncrossing cycle on a 3 x 5 torus that has length > 10 and 
meets the polygon constraint is the example shown above. 

Can you find the unique cycle of noncrossing knight moves on a 4 x 4 
torus that forms a 10-gon? (Please don’t peek at the answer below until 
you’ve tried.) 


486 Selected Papers on Fun and Games 

Uncrossed knight paths turn out to be equally interesting when ex- 
tended to toruses. In this case we want the corresponding path in the 
plane to begin and end in the same m x n box. Under this restriction 
the 3x5 torus admits only one noncrossing path of length 11, and that 
path wanders rather far afield before coming home: 



(Again we can make an infinite tiling.) I challenge the reader to find all 
of the noncrossing paths on a 4 x 4 torus that make 11 knight moves. 
It’s a pleasant recreation, and one of the solutions is quite surprising. 

I looked also at 4 x 5 toruses; but decided not to pursue this pleasant 
recreation any further at the moment, because (a) I don’t want to spoil 
the readers’ fun, and (b) toroidal tours are better suited to good-old 
backtracking than to the newfangled ZDD approach. I’m sure, however, 
that many delightful designs based on noncrossing toroidal moves are 
“out there” ready to be discovered. 

Research on uncrossed paths can also be pushed in quite a different 
direction: Knight paths can be “warped” as well as “wrapped” ! The im- 
ages of noncrossing paths obviously remain noncrossing when we distort 
them with fancy lenses, and a new kind of pattern arises. 

Consider, for example, the following three versions of Dawson’s orig- 
inal uncrossed knight path: 



On the left we have “stereographic projection,” obtained by placing a 
sphere atop the original image with the south pole on the center and 
projecting onto the sphere’s lower surface, where the sphere’s radius is 
chosen so that the equator lies directly above the four corner points. On 
the right, we have “radial distortion,” obtaining by scaling each point 
by its distance from the center. In all three cases the square’s center and 
four corner points remain fixed. The paths change dramatically, with 



Uncrossed Knight’s Tours 487 


central features emphasized in the stereographic version but shrunken 
in the radial version. And the lengths change too, of course; the original 
Euclidean length, 78.262, is 35\/5. 

Therefore we ask, “What uncrossed knight path is longest, in the 
stereographic projection?” Such a path shouldn’t be as sparse in the 
middle as Dawson’s original; and it turns out that the best has length 34 
in the unwarped sense: 





length 109.776 length 76.026 length 50.142 
I know that this path is optimum, and uniquely so, because the ZDD 
representation makes it easy to solve any Boolean program, namely to 
find all solutions that maximize a linear combination J2 c i x i °f the vari- 
ables that are either present (1) or absent (0). (In our case, the variables 
Xi are the 168 possible moves of a knight on a chessboard; the coefficients 
Cj are the lengths of their stereographic images.) 

Similarly, it’s easy to find the noncrossing path that is radially 
longest, and the uniquely best one turns out to have only 31 steps: 




length 84.607 length 69.318 length 58.536 
I think only a computer could have figured this out. 

Finally, let’s consider the optimum warped cycles. From a stereo- 
graphic standpoint, Pauly’s original 32-cycle from 1930 is still best: 





■ 


488 Selected Papers on Fun and Games 

But radius-stretched warping prefers the following unique 30-cycle: 



length 85.834 



length 67.082 



length 53.431 


Answers 

The maximum-length uncrossed knight paths on a 4 x 5 board are: 



(In fact, the left-hand one was implicitly mentioned on the very first 
page of this chapter.) 


Here is the 10-gon for a 4x4 torus, together with the five noncrossing 
11-paths: 



(The last one is the surprise: It really doesn’t cross.) By the way, the 
5x4 torus hosts a nice 14-gon, and four amazing 15-paths: 




Chapter 41 


Celtic Knight’s Tours 


[The following previously unpublished notes, written on Saint Patrick’s 
Day (2010), are based on experiments that I carried out during the 
Christmas holidays of 1992.] 

The fascinating problem of discovering a knight’s tour a sequence of 
moves by which a knight can visit every square of the chessboard exactly 
once — has been studied for nearly 1200 years, yet many natural ques- 
tions about such tours remain unanswered. One such question, based 
on the appealing diagrams that arise when we trace out a sequence of 
knight moves, is considered and partially answered in the notes below. 

This investigation began when I read Vandermonde’s classic memoir 
on the subject [“Remarques sur les problemes de situation,” Memoires de 
Mathematique et de Physique, tires des registres de 1'Academie Royale 
des Sciences (1771), part 1, 566-574 and plates X, XI], in which he in- 
troduced three-dimensional knight’s tours on a 4 x 4 x 4 cube and related 
the paths to threads, in patterns for weaving. I was struck by the qual- 
ity of the illustrations in his paper, which were much more refined than 
those I’d seen in 20th-century publications; see, for example, Fig. 1. 




Figure 1. Details enlarged from Vandermonde’s Figure 4 and Figure 5. 


489 


490 Selected Papers on Fun and Games 

Hmmm, I thought: Wouldn’t it be nice if my books on The Art of Com- 
puter Programming could have illustrations that approach the quality 
that was achievable in the 18th century? 

Meanwhile my wife and I had become interested in the interlacing 
patterns of what is popularly called Celtic art, after having spent two 
glorious weeks in Ireland during the spring of 1992. We had seen many 
examples of graphic design and jewelry that featured intricate, entangled 
paths such as those in Figure 2: The path is basically two-dimensional, 
yet it avoids self-intersection by alternately passing over and under itself, 
achieving a three-dimensional effect. 


FIGURE 2. A decorated letter ‘v’ 
from the ninth-century Book of Kells 
[actually the letter ‘u’ in ‘autem’, 
part of Mark 15 : 24, folio 183 r ] . 



Thus when I read Vandermonde’s ideas about constructing knight’s 
tours, it was only natural for me to imagine redrawing the example he 
had given for an ordinary chessboard, one-fourth of which was shown at 
the right of Figure 1 above, by rendering it instead as a “Celtic knot” : 



FIGURE 3. Vandermonde’s 
tour of 1771, redrawn as 
an interlaced path. (Look 
closely at the crossings.) 


With a wee bit o’ imagination one can even perceive a shamrock here! 


Celtic Knight’s Tours 491 

Can any cycle of knight moves be drawn in this way, with the path 
alternately going under then going over whenever it meets itself? Yes 
it can. In fact, the under-and-over property is true for any closed curve 
in the plane that doesn’t go through any point more than twice. I’m not 
sure who first discovered this principle — perhaps it is quite ancient — 
but the great mathematician C. F. Gauss stated it without proof in one 
of his notebooks, dated 30 December 1844 [“Zur Geometrie der Lage, 
fur zwei Raumdimensionen,” published in Carl Friedrich Gauss, Werke 
8 (Leipzig: Teubner, 1900), 282-286]. A simple proof can be based on 
the fact that the curve partitions the plane into regions that can be 
colored either white or gray, depending on whether a straight line from 
the region to the “outside” crosses the curve an even or odd number 
of times. Given such a two-coloring, consider the curve segments that 
go counterclockwise around each gray region; we can assume that they 
pass under the next segment, at each crossing point. This rule gives a 
consistent way to tell which strand is on top whenever two strands cross, 
and it alternates between up and down as desired. 


Figure 4. The under-and- 
over property is explained 
by two-coloring the regions. 



The effect of interleaving is easiest to see when the path is wide; 
but if the path crosses itself in three places that are extremely close 
together, we must thread it through a small trian- 
gle. A knight path comes pretty close to having 
a triple point if it contains the three moves shown 
here; these three moves intersect at the corners of a 
tiny triangle, whose area is just l/120tli of the area 
of a chessboard square. The tour in Figs. 3 and 4 
contains twelve of these tiny triangles, so its path must be rather narrow. 



492 Selected Papers on Fun and Gaines 

Let’s say that a closed knight’s tour is Celtic if it doesn’t contain any 
such tiny triangles. Celtic tours make attractive “Celtic knot patterns” 
when we draw them with interlacing, because we can make the paths 
wider than they were in Figs. 3 and 4. For example, here’s a 6 x 6 Celtic 
cycle shown with both narrow and wide paths: 




Figure 5. A Celtic tour discovered in Berlin. 

This particular cycle has the honor of being the first Celtic tour ever pub- 
lished, because Leonhard Euler presented it on the next-to-last page of 
his famous essay on the knight’s tour, “Solution d’une question curieuse 
qui ne paroit soumise a aucune analyse,” Memoires de l’Academie Royale 
des Sciences et Belles-Lettres (Berlin, 1759), 310-337. Of course Euler 
didn’t realize at the time that it was “Celtic” ; but he did remark that 
the path is symmetric under 180° rotation. This tour also has another 
claim to fame, namely that it’s the only 6x6 knight’s cycle for which 
8 of the 36 moves are intersected by at most four other moves, and the 
remaining 28 moves are crossed by at most three others. 

There are 1245 different 6x6 knight’s cycles in all, and only one be- 
sides Euler’s turns out to be Celtic. The lesser-known one also happens 
to be the only 6x6 tour with 15 “x-crossings” : 30 out of its 36 moves 
are parts of x’s. (See Fig. 6.) It was found by George Jelliss in Decem- 
ber 1992, shortly after I had asked him if he thought Celtic tours might 
exist. Celtic tours are impossible on rectangular boards with fewer than 
36 squares; thus Figs. 5 and 6 contain the smallest possible examples. 
Figure 6 also shows three other Celtic tours due to Jelliss, including two 
8x8 tours with 180° symmetry chosen from more than 50 that he had 
found before Christmas. The 10 x 10 example is even more symmetrical: 
It remains unchanged under 90° rotation — a feat that is possible only 
on boards of size (4fc+2) x (4fc+2). It’s the first knight’s tour ever to 
be explicitly called Celtic in print. [G. P. Jelliss, “10 x 10 knight’s tours 


Celtic Knight’s Tours 493 




Figure 6. Celtic tours discovered in St. Leonard’s-on-Sea. 


with quaternary symmetry,” The Games and Puzzles Journal 2, #16 
(May 1999), 286-287.] 

The 8x8 tour at the lower right of Fig. 6 is particularly interesting 
because it intersects itself only 76 times. Jelliss presented it as a can- 
didate for the honor of “knight’s cycle on an ordinary chessboard that 
has fewest crossings when drawn on the plane.” He constructed it by 
changing just four links of the elegant pattern in Fig. 7, which has 90° 


494 Selected Papers on Fun and Gaines 

rotational symmetry. Notice that Fig. 7 consists of four quarter-tours , 
which are cycles of length 16 that cover the entire board when taken 
together; moreover, these quarter-tours do not intersect themselves. 



Figure 7. A noncrossing 
16-cycle, interwoven with 
three copies of itself to make 
a pleasant Celtic pattern. 


I decided to test Jelliss’s conjecture by examining all of the 8x8 
knight’s cycles that are symmetric under 180° rotation. There are ex- 
actly 608,233 essentially different cycles with that property, and they 
can all be constructed and analyzed in less than a minute on a modern 
desktop computer. It turns out that 2321 of them (about 0.382%) are 
Celtic, and nine of the Celtic ones are slightly better than the example in 
Fig. 6, with only 74 intersections. But the overall winner is non-Celtic; it 
has only 70 intersections, and it is unique. Furthermore, the maximum 
number of intersections among all symmetric cycles is 122, and there is 
just one way to achieve that many. (See Fig. 8.) The average symmetric 
tour has 94.02 intersections, with a standard deviation of about 5.57; 
thus extreme cases like these are quite rare. 

The total number of essentially distinct 8x8 knight’s cycles is known 
to be 1,658,420,855,433 [Brendan McKay, “Knight’s tours of an 8 x 8 
chessboard,’ Technical report TR-CS-97-03 (Australian National Uni- 
versity, February 1997), 4 pages]; so I’ve considered only a tiny fraction 
of them. Some day I want to generate them all, and to learn the true 
minimum and maximum number of self-intersections. 

I’ve taken one step in this direction already, by looking more closely 
at the eight moves that touch the four central squares of a chessboard 
in any complete tour. For example, I studied all of the 8x8 cycles 
for which those eight moves agree with the central pattern on the left 
of Fig. 8, because such parallel lines certainly cover a lot of territory 


Celtic Knight’s Tours 495 




without crossing. Exactly 6,964,213 essentially different knight’s cycles 
have four parallels in the center; 1981 of them are symmetric, 218 are 
Celtic, and 15 are both symmetric and Celtic. It turns out that only two 
of the asymmetric cases have as few as 70 self-intersections. One of these 
is shown in Fig. 9; the other is obtained by replacing the chess moves 
e3-f5 and fl-g3 by e3-fl and f5-g3, respectively. Similarly I considered 
all of the distinct 8x8 knight cycles whose centers have the non-Celtic 
configuration on the right of Fig. 8. In this case there are 1278 symmetric 
solutions and 12,546,275 that are asymmetric. Only one of them, shown 
in Fig. 9, attains 126 intersections, the current record. 



FIGURE 9. Asymmetric 8x8 cycles that may minimize and maximize intersections. 


496 Selected Papers on Fun and Games 

Exactly 18,941,491 of the 1,658,420,855,433 cyclic knight’s tours 
of the ordinary chessboard are Celtic. That’s about 0.00114%, a ra- 
tio nicely consistent with the 0.382% that was discussed earlier for 
symmetric tours. (A symmetric tour must essentially be Celtic on 
half of the board; a general tour must be Celtic on both halves, and 
0.382% X 0.382% « 0.00146%.) I recently figured out how to generate 
all the Celtic 8x8 tours with an algorithm that runs more than 600 times 
faster than the classical backtrack procedure I’d used in 1992, by adapt- 
ing the ideas of “dancing links” to the problem of finding Hamiltonian 
cycles with restrictions. As a result of this study, I now know the Celtic 
tours that minimize and maximize self-intersections: There are just two 
ways to achieve only 72 crossings Celtically, and the Celtic tour with 108 
crossings is unique. (See Fig. 10; to get the other 72-crossing example, 
change the moves d5-f4 and f6 h5 respectively to d5-f6 and f4 h5.) 




Figure 10. The Celtic 8x8 cycles that minimize and maximize intersections. 

Let’s zoom in now and take a closer look at the geometry of inter- 
sections. A knight move that isn’t too close to the edge of the board 
can be crossed by nine other moves, as shown in Fig. 11. (Only seven 
of those nine can occur simultaneously in a single tour; and symmetric 
tours exist in which four of the 64 moves are in fact intersected seven 
times. See G. P. Jelliss, “Intersections in knight tours,” Chessics 2, num- 
ber 19 (Autumn 1984), 25-27.) The intersection points are not equally 
spaced: The distance from point 1 to point 2 in the illustration is 1/4 
of the distance from point 0 to point 1, and it’s only 1/20 of the length 
of the full knight move from point 0 to point 10. 



• • 


Celtic Knight’s Tours 497 


Figure 11. The nine 
potential intersections of 
a knight move from 0 to 10. 
(Small numbers in italics 
indicate relative distances 
between intersection points.) 


Two moves are perpendicular when they cross at points 1, 4, 6, or 9 
in this diagram. The crossing pattern ~\~ in such cases is unsymmetrical, 
with one arm of the cross cut in the ratio 3:2 while the other has the 
cut-ratio 1:4. The non-perpendicular types of crossings are more sym- 
metrical: For example, at points 2 or 8 the pattern is .-X, with both 
arms cut in ratio 1:3. In this case the arms cross at angles a « 53.13° 
and 180° — a « 126.87°, where a = 2arctan | = arctan |. At points 3 
or 7 the pattern is with cut ratios 1:2 and sharper crossing angles 
a = arctan | « 36.87° and 180° — a « 143.13°; notice that a — 90° — a. 
Finally, the most symmetrical crossing of all occurs at point 5, where 
the pattern x has cut ratios 1:1; again the angles at the crossing point 
are a and 180° — a = 90° + a. 

The only possible angles between consecutive knight moves are a , a, 
and 90°; and we’ve now seen that these are also the only possible angles 
between intersecting moves. Hence the only possible triangles formed by 
knight paths are right triangles, with the three distinct angles a, a , 90°. 
In fact such triangles are famous, because their sides have the well-known 
proportions 3:4:5 of the smallest right triangle with integer sides. 

If a chessboard is composed of squares that have length s on each 
side, the units of length indicated by italic numerals in Fig. 11 are u = 
\/5s/6 0. The tiny triangles that are forbidden in Celtic tours have sides 
of lengths 3 u, 4 u, and 5 u; eight of them can be spotted in Fig. 11, if one 
looks closely. Their area is 6u 2 = s 2 /120, as stated earlier. 


498 Selected Papers on Fun and Games 

The entire chessboard has 240 places where such 3-4-5 triangles 
might arise; Fig. 12 indicates all of the possibilities: 


fi o o o 

3 O Q Q 

* O GO 

> O O 

3 A O O 


tj Q t 

O O i 
0 O ! 
O O 1 
O O 1 


Figure 12. The tiny 
triangles that must be 
avoided if a knight’s 
tour is to be Celtic. 


In general, all triangles obtainable as subsets of knight paths must 
have side lengths 3 ku, 4 ku, 5ku, for some integer k > 1. The area will 
then be 6 k 2 u 2 = k 2 s 2 / 120. Let’s say that such triangles have “type k. v 
A knight’s tour is Celtic when it contains no type-1 triangles. 

George Jelliss [“Knightly triangles,” The Games and Puzzles Journal 
2, #17 (October 1999), 315] has proved a remarkable theorem about 
type-fc triangles: Given k > 1, there is essentially only one way to 
construct a triangle of type k from three segments of a knight path. For 
example, a triangle of type 2 arises only when we have an x intersection 
together with another move that makes a intersection with one arm 
of the x and a intersection with the other. (This situation arises 
in Fig. 11 if and only if the move from 0 to 10 is intersected at points 
{1,3}, {3,5}, {4,5}, {5,6}, {5,7}, or {7,9}; the six possibilities are 
geometrically equivalent.) 

His proof is sketched in Fig. 13, based on the three ways that the 
angle a can be formed, with right triangles cut off at distances 4 ku 
on one side, 5ku on the other. Notice that the knight will turn at 
some corner of the triangle if and only if k is divisible by 3, 4, or 5. 
When k > 7 we need more than three moves to form the whole triangle, 
except in the interesting case k = 12. When k = 12 or k > 15 the 
triangle contains interior points; such triangles will be intersected by 
other moves of a complete tour, so they won’t appear as white or gray 
triangles when the planar regions defined by the cycle are two-colored 
as explained above. On the other hand, a type-2 triangle formed by 


Celtic Knight’s Tours 499 



FIGURE 13. Unique recipes for triangles of types 3 k + 1, 3fc + 2, 3 k + 3. 


a knight’s path doesn’t necessarily 
show up as a triangle in the two- 
coloring; it might be cut by another 
part of the path into a triangle of 
type 1 plus a “kite” shape of area 
s 2 /40. Similarly, a type-3 triangle in 
a Celtic tour might contain triangles 
of type 2, or it might be “nicked” by 
type-2s that lie near its periphery. 

The board must of course be 
larger than 8 x 8 if we want a type-fc 
triangle when k is large; but all sizes 
up to type 33 are possible on an or- 
dinary chessboard, except for k = 
31. And type 36 is possible too: In 
fact, triangles of type 36 appear in 
exactly 49,247,382 different knight’s 
cycles, 650 of which are Celtic like 
the one shown here. 

A type-A triangle will be a cy- 
cle when k is a multiple of 60, with 
the knight turning at each corner; it 
can’t be part of a tour in that case. 

Figure 15 shows the only exam- 
ple I know of a knight’s cycle with 30 
triangles of type 1 and 40 of type 2. 
(The right-hand example in Fig. 9 
has 44 of type 2, but “only” 29 of 
type 1.) Is this the “least Celtic” of 
all knight tours on the chessboard? 



FIGURE 14. Type 36 the max. 
(Maybe we should call it “type 4.”) 



Figure 15. Many small triangles. 







500 Selected Papers on Fun and Games 

By studying the limited possibilities for a knight to maneuver near a 
corner, Jelliss noted in 1992 that every knight’s cycle on the chessboard 
must have at least one triangle of type 2. Thus no “super-Celtic tours,” 
in which all triangles have types 3 or more, are possible. In fact, one 
can see without difficulty that a type-2 triangle must appear somewhere 
in the upper left quadrant of the board unless all of the following moves 
are present: 



Figure 16. This is what 
happens when we try to 
forbid type-2 triangles. 


And then it’s easy to see that at least two type-2 triangles must appear 
in the upper right quadrant, and two more in the lower left. Thus we 
can conclude that every knight’s cycle on the chessboard contains at 
least four triangles of type 2. And indeed, this lower bound is optimum; 
there are, for example, four symmetric tours that contain just one type-2 
triangle in each quadrant. 



Figure 17. A knight’s cycle 
that has only four triangles 
of type 2 (and ten of type 1). 


Celtic Knight’s Tours 501 
(b) 



(c) 




Figure 18. Some of the extreme ways to extend Figure 16. 

The pattern in Figure 16 can be completed to a full knight’s cycle in 
exactly 52,359,773 ways, four of which are symmetrical. [Jellies exhibited 
two of the symmetric examples in Chessics 2, number 19 (Autumn 1984), 
25-27.] None of them are Celtic, but Fig. 18(a) shows a case with only 
two type-ls; it has thirteen of type 2. Fig. 18(b) illustrates the fact that 
one can have only 70 self-intersections without using the central parallel- 
lines pattern of Figs. 8 and 9. The total number of type-2 triangles under 
the constraint of Figure 16 can never be less than 6, as in the example 
of Fig. 18(c); it reaches its maximum, 29, uniquely in Fig. 18(d). 



502 Selected Papers on Fun and Games 

If Fig. 15 is the least Celtic of all chessboard tours, which tour is 
most Celtic? I nominate Fig. 19(a), which not only has just eight type-2 
triangles (the minimum, when type-ls are forbidden), it also has only 
four intersections (the minimum over all knight’s tours); furthermore 
it’s nicely symmetric. Another noteworthy example is Fig. 19(b), which 
may well be the only knight’s tour — Celtic or not — with the astonishing 
property that 60 of its 64 moves are part of an x intersection. The 
tour in Fig. 19(c) is one of several that have only 14 intersections of the 
perpendicular ~j“ type; I know of no non-Celtic tours with fewer than 16 
such intersections. Celtic tours don’t like “1“ crossings; there’s only one 
such tour, Fig. 19(d), with as many as 50 of them. 


FIGURE 19. Record-breaking Celtic cycles of particular interest 


Celtic Knight’s Tours 503 

Celtic tours make pleasant patterns on boards of many other sizes, 
especially because we can often find symmetries that are impossible 
on an ordinary chessboard. Three types of symmetry are possible for 
knight’s cycles on rectangular boards, and all three can be achieved 
without type-1 triangles when the board size is 10 x 5 (see Fig. 20). 



FIGURE 20. Symmetries a la (a) rotation, (b) Bergholt, and (c) reflection. 


To understand the difference, consider the same three tours pre- 
sented as arrays of numbers, where the knight hops from 0 to 1 to 2 
to • • • to 49 and then back to 0: 


(a) 


0 

47 

34 

15 

2 

35 

14 

1 

48 

33 

46 

49 

32 

3 

16 

13 

36 

17 

44 

31 

18 

45 

30 

37 

4 

29 

12 

5 

20 

43 

6 

19 

42 

11 

38 

41 

28 

7 

24 

21 

8 

23 

26 

39 

10 

27 

40 

9 

22 

25 




(b) 



5 

2 

33 

10 

7 

34 

9 

6 

3 

32 

1 

4 

27 

8 

11 

26 

35 

12 

31 

28 

19 

0 

29 

24 

13 

36 

25 

20 

49 

30 

21 

18 

37 

14 

23 

38 

41 

22 

45 

48 

17 

46 

43 

40 

15 

42 

39 

16 

47 

44 


0 

39 

6 

45 

2 

5 

46 

1 

40 

7 

38 

49 

42 

3 

44 

11 

4 

47 

8 

41 

48 

37 

10 

43 

34 

23 

12 

35 

18 

9 

36 

29 

22 

33 

16 

13 

24 

17 

28 

19 

30 

21 

26 

15 

32 

25 

14 

31 

20 

27 


504 Selected Papers on Fun and Games 

In case (a), the pairs of numbers that lie opposite each other with respect 
to the center are {0, 25}, {47, 22}, {34, 9}, . . . , {37, 12}, {4, 29}; they all 
differ by exactly 25, which is half the total number of knight moves. 
But in case (b), the corresponding pairs are {5,44}, {2,47}, {33,16}, 
. . . , {24, 25}, {13, 36}; here they have constant sum , 49, instead of a con- 
stant difference! In both cases the diagrams of moves remain unchanged 
under 180° rotation about the center; but when Fig. 20(b) is rotated, 
the cycle also changes direction, so the tour goes backwards. Symmetry 
of this kind for knight cycles was discovered by Ernest Bergholt, who 
discussed it briefly in British Chess Magazine 38 (1918), 104, 195. [He 
had written at length to W. W. Rouse Ball about the subject in 1917; 
his letter was discovered among the papers of H. J. R„ Murray and pub- 
lished in The Games and Puzzles Journal 2 , #14 (16 December 1996), 
233-237.] 

Case (c) is rather different and somewhat more rare; it involves mir- 
ror reflection about a horizontal axis, instead of rotation. Here we find 
that the number pairs {0,25}, {39,14}, {6,31}, ..., {43,18}, {34,9}, 
which lie vertically opposite each other, all differ by 25. 

A knight’s tour can have rotational symmetry as in case (a) on m x n 
boards only when m and n are both even, or when one of them is odd 
and so is mn/2. Bergholtian symmetry as in case (b) can occur only 
when either m or n is odd. And reflection symmetry as in case (c) is 
possible only when mn/2 is odd. 

Here’s a table of the total number of geometrically distinct Celtic 
cycles on m x n boards, for m < n and mn < 66: 


5 x 10: 530(8,5,7) 

5 x 12: 21230(0,31,0) 
6x6: 2(1, 0,0) 

6x7: 52(2,0,3) 

6 x 8: 1568(28,0,0) 


6 x 9: 31437(69,3,73) 

6 x 10: 596485(676,0,0) 

6 x 11: 11715215 (1274, 180, 848) 

7 x 8: 284003(0,21,0) 

8 x 8: 18941491 (2321,0,0) 


Symmetric counts for types (a), (b), and (c) are shown in parentheses; 
for example, a 5 x 10 board admits 530 Celtic cycles, of which 8 are 
symmetric under 180° rotation, 5 have Bergholtian symmetry, 7 have 
mirror symmetry, and the other 510 are asymmetric. Board sizes not 
shown have no Celtic cycles. 

So far we’ve been considering only knight’s tours that are closed; but 
open tours, in which the knight traverses all cells of the board without 
returning to the starting point, also make attractive Celtic patterns. (In 
fact, many of the interlacing patterns in the Book of Kells are paths 


Celtic Knight’s Tours 505 

rather than cycles.) The smallest examples occur on 4 x 5 boards, which 
support three different Celtic paths, two of which are symmetric: 





Notice that symmetry of open tours under rotation or reflection always 
reverses the direction of the path in Bergholtian fashion. 

Open knight’s tours of the 4x8 board have been studied for more 
than 1000 years, because they can be used to make symmetric cycles 
on the full 8x8 board if the endpoints occur in fortuitous places. For 
example, we can use the open tours 




and hook them up with their rotations to form complete Celtic cycles: 



The only 
metrical open 
1992 : 


Celtic Knight’s Tours 507 

When the next size, 5 x 6, is considered, a new problem arises that I 
didn’t realize until many years later: If the complete diagram of knight 
moves disconnects the two endpoints from each other, we cannot draw 
the tour with the perfect up-and-down interlacing of a Celtic knot! Con- 
sider, for example, the following two open tours: 




The left-hand one is fine, but on the right we can’t manipulate the 
“threads” without breaking the under- and- over rule. In fact, our proof 
by which we showed that closed tours can always be properly threaded 
also shows why the threading is impossible in open tours such as this one. 

Hmm; a tour that deserves to be called Celtic should always be 
presentable as a Celtic knot. We must therefore refine our definition of 
Celtic knight’s tours: Not only should the tour avoid any three moves 
that are nearly concurrent because of type-1 triangles, the endpoints of 
an open tour must be reachable from each other without crossing over 
any of the knight moves. This new criterion excludes 7 of the 80 open 
tours on a 5 x 6 board that would otherwise qualify for Celticness. 

If both endpoints occur at the outer edge of the board, namely in 
the top or bottom rows or in the leftmost or rightmost columns, there 
is no problem. And we can also sometimes connect interior endpoints 
together without crossing any moves. For example, here are some 6x6 
examples that are thoroughly Celtic in spite of having interior endpoints: 


508 Selected Papers on Fun and Gaines 

For the record, let’s list the total number of distinct open Celtic 
tours on to x n boards, for all board sizes m < n and mn < 36 that 
support at least one open tour: 


3 

X 

00 

3(2) 

4 

X 

9 

559(5) 

4 

X 

5: 

3(2) 

5 

X 

5 

1(1) 

4 

X 

6: 

16(0) 

5 

X 

6 

73(0) 

4 

X 

7: 

32(6) 

5 

X 

7 

601(28) 

4 

X 

8: 

122(0) 

6 

X 

6 

668 (0) 


As before, symmetric counts appear in parentheses. 

One can show without difficulty that complete Celtic cycles are im- 
possible on 3 x n boards. However, there are some nice ways to construct 
open 3 xn tours that have unimpeachable Celtic credentials. George Jel- 
liss proved in 1993 that the endpoints of such tours must lie in the top or 
bottom rows, and that one endpoint must be in the second column from 
the left while the other is in the second column from the right; hence n 
must be even. He found all ten of the geometrically distinct tours in the 
smallest feasible case after n = 8, namely n = 16; four of them, like the 
following example, are symmetrical: 



The first five moves of any Celtic 3 x n tour, as well as the last five 
moves, can be independently flipped about a horizontal axis, thereby 
allowing each endpoint to appear either at the top or bottom. The 
number of geometrically distinct solutions, for 16 < n < 24, is given by 
the following table: 

n= 16 17 18 19 20 21 22 23 24 

sols — 10 (4) 0(0) 16(0) 0(0) 42(4) 0(0) 116(8) 0(0) 196(8) 

In fact, the set of all 3 xn Celtic knight’s tours can be fully analyzed, 
using methods that apply to 3 xn knight’s tours in general; those meth- 
ods are explained in the next chapter. The total number of 3 x n tour 
diagrams can be shown to be the same as the number of oriented paths 


Celtic Knight’s Tours 


509 



from Start to Stop in Fig. 21. The corresponding generating function 
T(z) = 8z 8 + 32z 16 + 64s 18 + 0(z 20 ) turns out to be 

T(z) = (8 z 8 - 32z 12 - 64z 18 + 256z 20 + 320 z 22 - 512z 24 

- 576z 26 - 512z 28 + 256z 30 + 1024z 32 )/C(z 2 ), where 
C(z) = 1 - 4z 2 - 4 z 4 - 16z 5 + 28z 6 + 16z 7 - 64z 8 - 16z 9 
-48z 10 +64Z 11 +64z 12 ; 

and the generating function S(z) — 2 z 4 + 4z 8 + 4z 10 + 8Z 11 + 0(z 12 ) for 
half of a symmetric tour is 

S(z) = (2 z 4 - 4z 8 + 4z 10 + 8z 14 - 16z 12 

+ 8z 13 - 24z 14 + 32z 16 + 32z 17 + 16z 18 
- 48z 19 - 96z 21 - 32z 22 - 32z 23 - 64z 24 
+ 128z 26 + 128 z 27 )/C(z 2 ). 

The generating function G(z) = 3z 8 + 10z 16 + 16z 18 + 0(z 20 ) for geo- 
metrically distinct solutions is then T(z)/4 + S(z 2 )/ 2. 

Let’s close by contemplating the following remarkable 3 x 40 Celtic 
tour, which is readily extended to boards of size 3x8 n for any n > 2: 



Chapter 42 


Long and Skinny Knight’s Tours 


[The following previously unpublished notes are based on research that 
I couldn't resist pursuing during Easter week of 2010, while editing the 
previous chapter for publication.] 

The m x n knight graph is the graph of mn vertices (i, j) for 0 < i < m. 
and 0 < j < n, with (i,j) — (?', j 1 ) if and only if ( i — i 1 ) 2 + (j — j 1 ) 2 — 5. 
In other words, it’s the graph whose vertices are the cells of a chessboard 
with m rows and n columns; two cells are adjacent if a knight can move 
from one to the other. The smallest interesting cases occur when m — 3 
and n > 4. 

The study of Hamiltonian paths and cycles on these 3 Xn graphs has 
a long history going back to Euler [4, §42], who found all Hamiltonian 
paths of the 3x4 board, namely 



up to symmetry, and stated (correctly) that no such paths exist on 3 x 5 
or 3 x 6 boards. Euler exhibited two examples of 3 x 7 tours, 



thereby showing that the total number of cells could be odd. He also 
stated (incorrectly) that Hamiltonian cycles on the 3xn knight graph are 


511 


512 Selected Papers on Fun and Games 

impossible, and other authors propagated this widely believed statement 
for more than 150 years. Suddenly Ernest Bergholt surprised everybody 
by discovering cycles on the 3 x 10;* the first example he found [1, 2] was 



An excellent exposition of the history and theory of 3xn knight’s 
tours, for small n, has been prepared by G. P. Jelliss [5,6]. The purpose 
of the present note is to count the total number of such tours that exist 
for arbitrarily large values of n. For example, we’ll be able to deduce 
without great difficulty that the 3 x 100 knight graph has exactly 

17,171,285,160,376,241,062,521,061,238,260,619,247,832,232,930,992,568 

Hamiltonian paths, and that it has exactly 

4,861,943,174,181,138,724,903,568,742,746,024,250,554,974,208 

Hamiltonian cycles. (Every Hamiltonian cycle on this graph leads to 
300 of the Hamiltonian paths, by deleting one of the edges. Those 
paths are said to be reentrant.) As a byproduct of our investigations 
we’ll encounter several elementary facts about 3 x n tours that are of 
independent interest, as well as some very pleasant new patterns. 

* When I read Euler’s paper carefully for the first time in 1972, I scribbled 
the following notes on my copy: “Impossibility not proved, nor is it plainly 
stated that reentrancy is impossible on 4 x n, or boards with odd no. of 
cells. [I didn’t really understand Euler’s French wording.] Here’s a 3 x 14 
[based on a 3 x 7 path; go from 1 to 21, then 1' to 21']: 


9 

12 

7 

4 

17 

14 

19 

21' 

18' 

15' 

2' 

5' 

8' 

ir 

6 

3 

10 

13 

20 

1 

16 

16' 

T 

20' 

13' 

10' 

3' 

6' 

11 

8 

5 

2 

15 

18 

21 

19' 

14' 

17' 

4' 

7' 

12' 

9' 


Exercise: Characterize 3 x n that admit reentrancy. ... I believe I’ve proved 
without great difficulty that 3x6, 3x8, 3 x 10 are impossible. . . . Addendum. 
12 Dec 92: Altogether 176 solutions 3 x 12. And there are 16 solutions of 
the 3 x 10! Also 1536 solutions of 3 x 14.” [I had begun my study by 
reading the major reference books on recreational mathematics, which were 
written before 1918, so I didn’t learn of Bergholt ’s work until later.] 


Long and Skinny Knight’s Tours 513 


The Basic Setup 

Our main tool will be a directed graph K, called knight3, which encap- 
sulates all of the information about 3 x n knight’s tours for arbitrary n 
in a single structure. This digraph K turns out to have 712 vertices and 
5506 arcs. The vertices of K represent the “states” that can arise when 
we take a 3 x n tour and cut it into two pieces, consisting of k columns 
at the left and n — k columns at the right, for some k. The arcs of K 
represent the allowable transitions between states when k increases by 1 . 

Let S n denote the 3 x n knight graph, and let S n be its extension 
obtained by adding a new vertex oo that is adjacent to all the oth- 
ers .^Hamiltonian paths T in S n are equivalent to Hamiltonian cycles T 
in S n , where the two endpoints of T are the two neighbors of oo in T. 
Throughout the following discussion, we will bear in mind that S n and 
S n are undirected graphs, which have edges (moves) between cells; K, by 
contrast, is a directed graph, which has arcs (transitions) between states. 

Given a Hamiltonian cycle T on S n or S n , let T k = T | S k be the 
edges of T that lie entirely in the first k columns of the chessboard, 
possibly extended by oo. Thus, for example, in Euler’s first 3x4 tour 
as given above, and with the rows numbered 0, 1, 2 from top to bottom, 
we have 

T = T 4 = {oo — 10, 10-02, 02-23, 23-11, 11-03, 03-22, 

22-01, 01-20, 20-12, 12-00, 00-21, 21-13, 13-oo} 

and T 2 = {00 — 10, 01 — 20, 00 — 21}, where the notation ij — i'j' stands 
for the edge from ( i,j ) to ( i',j '). 

In general, every cell of S k will be covered by exactly two edges 
oi T k , except perhaps for 00 and for cells in the two rightmost columns 
of S k . The uncovered cells are either untouched — that is, absent from 
all of T k s edges — or they are attached to some other cell by a single 
edge of T k . In the latter case, they are “mated” to a similarly attached 
cell, by a maximal subpath of T k whose endpoints are the two mates. 
Continuing the previous example, we have 

T 3 = {cjo-10, 10-02, 22-01, 01-20, 20-12, 12-00, 00-21}, 

and the uncovered cells of S 3 are 00 , 02, 11, 22, 21. Cell 11 is untouched, 
while the pairs { 00 , 02} and {22,21} are mates. 

It’s convenient to denote the seven possibly uncovered cells by the 
typewriter-style digits 1, 2, 3, 4, 5, 6, and 00 , denoting the respective 


514 Selected Papers on Fun and Games 

cells (0, fc-1), (l,fc-l), (2, fc— 1), (0, k—2), (l.fc-2), (2, fe— 2), and oo. 
In this notation the right end of the partial board S k is essentially 

4 1 

oo 5 2 , 

6 3 

although cell cd is actually off in limbo somewhere. Each of these seven 
cells x is assigned a mate, called mate[x\ , by the rules 

{ 0, ii x is covered by T 
x, if a; is untouched by T k ; 
y, if x and y are attached to each other via T k . 

The state corresponding to T k is then denoted by the seven-digit code 

mate[ 1] mate[ 2] mate[ 3] mate [4] mate [5] mate [6] mate[oo]. 

For example, the state corresponding to T 3 in Euler’s tour T is m060531. 
because cells (1, 2, 3, 4, 5. 6, oo) are respectively (02, 12, 22, 01, 11, 21, oo) 
when fc = 3. This state is a successor in K of the state that corresponds 
to T 2 , which happens to be state 6243ool5 according to these rules. 

To go from T k to T k + 1 in general, we begin by increasing all of the 
code numbers by 3 and then we append new untouched elements 1, 2, 3. 
thereby obtaining up to ten potentially relevant cells: 

7 4 1 

co 8 5 2 

9 6 3 

The remaining task is to take account of the edges of T that belong to 
Tfe+i but not to Xfc, namely those that have one endpoint in column k 
and another in columns fc - 1 or fc - 2 (or 00 ). This set of new edges 
is conveniently encoded by three italic digits, representing the sum of 
codes for each of the nine possibilities: 

1 00 for edge 8 — 1 010 for edge 7 — 2 001 for edge 4 — 3 

200 for edge 6 — 1 020 for edge 9 — 2 002 for edge 8 — 3 

400 for edge 00 — 1 040 for edge do — 2 004 for edge co — 3 

For example, T 3 has four edges that aren’t in T 2 in Euler’s tour T, and 
the transition from 6243ool5 to oo060531 has the code name 100 + 010 + 
020 + 001 = 131. Only 7 3 — 3 3 = 316 of the 512 potential transition 
codes abc are actually possible, because 0 < a, b, c < 6 and because at 
most two of the digits {a,b,c} can exceed 3. 


Long and Skinny Knight’s Tours 515 

Let’s watch the process of going from 6243ool5 to oo060531 in slow 
motion: First we upgrade 6243®15 to 1239576oo48, as k is increased 
from 2 to 3. Then we add edge 100 , from 8 to 1 , obtaining oo239576041. 
Edge 010, from 7 to 2 , changes that to ®639520041; edge 020, from 
9 to 2, yields oo036540001; and the final edge 001, from 4 to 3, pro- 
duces the state ®060530001 that actually corresponds to T 3 . Of course 
the edges of Tk+i have by now covered 7, 8 , 9; so we leave out the 
'mate [7] mate[ 8 ] mate [9]’ part of the ten-digit code, obtaining the new 
seven-digit state code co060531. 

The operation of changing the mate values, as a new edge is added 
from x to y , might seem to require a complicated case analysis. But in 
fact, we simply need to do the following six assignments, in order: 

x' mat,e[x], y' <— mate[y \ ; 
mate[x ] 0, mate[y] <— 0; 

mate[x'] 4— y' , mate[y '] <— x' . 

The cases x' — x and/or y' = y do a bit of redundant computation, 
but we save time because we needn’t treat them specially. Notice, how- 
ever, that such a knight move is legal only when x' and y' are nonzero. 
Furthermore, we usually assume that x' 7 ^ y (hence y' ^ x). The excep- 
tional case, in which x' = y and y' = x, is allowed only when completing 
a Hamiltonian cycle, namely when all other mates are already zero; oth- 
erwise we’d be closing a cycle that is too short. If this case is permissible 
we omit the last two assignments of the scheme above, thereby closing 
the final cycle by setting both mate[x\ and mate[y] to 0 . 

With this machinery in place, Euler’s tour T is completely charac- 
terized as a path of length 4 in K : 

040 201 131 363 

000000® — t 1®30002 — t 6243®15 — > ®060531 — » 0000000. 

Indeed, we’ve set up a one-to-one correspondence between the open 
knight’s tours of a 3xn chessboard and the paths of length n from 
000000 ® to 0000000 in K. 

Similarly, it’s easy to see that the dosed tours are in one-to-one 
correspondence with paths of length n — 1 from 1230000 to 0000000. 
Bergholt’s closed tour on the 3 X 10 board corresponds to the path 

201 133 122 011 

1230000 — > 6243510 — > 6000510 — > 3412000 — > 1560230 

qpi pip inn pop qqq 

— > 0543200 2150300 — > 6235410 — » 6043510 — > 0000000. 


516 Selected Papers on Fun and Games 

State OOOOOOco is called the open source vertex of K , and denoted 
by the symbol <7 0 ; state 1230000 is called the closed source vertex, and 
denoted by o c . State 0000000 is the sink vertex, t. 

Symmetries 

Euler’s three tours on the 3x4 board give us three paths of length 4 
from (7„ to t in K. But we have to be careful when we count paths: 
We will see shortly that there are actually eight different shortest paths 
in K from o 0 to r, not three. Did Euler miss five of them? No. He 
found the three tours that are geometrically distinct; but the diagram 
of any given 3 x n tour leads to a different diagram when it is reflected 
about a horizontal axis. Sometimes we also get two further diagrams 
after reflecting about a vertical axis. Euler’s three tours lead in this way 
to2 + 4 + 2 = 8 different diagrams, and the one-to-one correspondence 
we have been discussing is a correspondence with respect to diagrams. 
Symmetry under reflection can indeed be accounted for; we just haven’t 
gotten there yet. 

We can, however, see easily that the top-to-bottom reflection pro- 
cess, which basically interchanges row 0 with row 2, does have a straight- 
forward effect on paths in K. Consider, for example, the relation between 
the path for Euler’s tour T and the path that corresponds to the tour V 
that we get by reflecting T about a horizontal axis; that tour is 

040 201 232 353 

OOOOOO 00 — » 1cd30002 — ► 6243ool5 — > 40ool503 —4 0000000. 

In general, every state a corresponds to a “flipped” state a', and every 
transition t corresponds to a “flipped” transition t' . If a = abcdefg and 
t = abc, we have a' = c'b'a'f 'e'd'g' and t' = c'b'a', where 

O' = 0, 1' = 3, 2' = 2, 3' = 1, 4' = 6, 5' = 5, 6' = 4, co' = co: 

O' = 0, 1' = 2, 2' = 1, S' = 3, 4' = 4, 5' = 6 , 6' = 5. 

Notice that a' 0 = o 0 , a' c = a c , and r' = r; also loo30002' = lco30002 and 
6243ool5' = 6243ool5. But 40col503' = co060531. 

We will defer further study of symmetry until we’ve completely un- 
derstood the situation when symmetries are ignored. 

Classification of States 

The state codes of K are all obtainable in principle by (a) starting with 
the sequence of seven digits 123456ra, then (b) setting some subset of 


Long and Skinny Knight’s Tours 517 

them to 0, and (c) applying an involution (a self-inverse permutation) 
to the remaining nonzeros. Thus the total number of possibilities is 

(7)*° + (e)*i + (5) *2 + (l)h + {l)t 4 + Qts + ([)t 6 + Qh, 

where tk is the number of involutions of k elements. 

The well-known formula ^2 k>0 tkZ k /k\ = e z+z / 2 (see, for example, 
[8, exercise 5.1.4-25]) implies that this sum is 7! [z 7 ] e 2z+z2 / 2 — 1850. 
However, only 1406 of the 1850 potential states are actually reachable 
from the source states cr 0 and cr c by legal transitions of knight moves. 
There’s no way to reach 1000000, for example. 

Another large set of states, having the forms *** 4 ***, *****6*, 
and ***6*4*, can easily be shown to have no successor; here “*’ is a 
“wild card” that matches any digit. Such states aren’t in K, because 
they don’t lead to r, and by excluding them from the reachable states 
we can whittle the number of possibilities from 1406 down to 750. We 
can also knock out states of the form 1*3*5**, whose successors have no 
successors, thereby removing six more reachable cases from the set. And 
another 32 cases, such as 1035400, fail to satisfy a necessary condition 
that is derived below, in spite of being reachable from o 0 . 

Thus we’re left with 712 vertices in K, as stated earlier. A simple 
computer program shows that each of these vertices, except <r c , actually 
occurs in some path of length 16 or less from a 0 to r. (In fact, only the 
two states 10300oo6 and 103oo004, which occur near the middle of 



or its reflection, require a path of length more than 14.) 

Cell (i,j) of the chessboard is said to be even when i + j is even, 
and odd when i + j is odd. A3 xn board has [3n/2] even cells and 
|_3n/2j odd cells. Therefore, when n is odd, the endpoints of an open 
tour must both be even. It follows that four different kinds of open tours 
are possible: 

1) Both endpoints appear in the same column; one of them is odd, the 
other is even, and n is even. 

2) Both endpoints appear in the same column; both of them are even, 
and n is odd. 


518 Selected Papers on Fun and Games 

3) The endpoints appear in different columns, and the left endpoint is 
even. The right endpoint is even if n is odd, odd if n is even. 

4) The endpoints appear in different columns, and the left endpoint is 
odd. The right endpoint is even, and so is n. 

We will see that these four cases show up naturally in the states of K. 

Let us divide the vertices of K into four classes, called 0 (open), 
F (free), B (bound), and C (closed). Class 0 consists of all states whose 
code names end with cd; these are the states that occur before any end- 
points of the tour have appeared. Class C consists of all states whose 
names end with 0; these are the states of closed tours, and they also 
occur after both endpoints of an open tour have been seen. Between 0 
and C we have two choices for the intermediate states, when one end- 
point has appeared but not the other: Class F corresponds to open tours 
of type (3) above, following an even left endpoint; class B corresponds 
to open tours of type (4), following an odd left endpoint. 

The states of classes 0, B, and C are bipartite, so we subdivide them 
further into classes 0 o , 0 l5 Bo, Bi, C 0 , and Ci. An 0 o or Bo state always 
occurs an even number of steps after ct 0 ; a B 0 or C 0 state always occurs 
an even number of steps before r. Classes 0i, B 1; and C x are similar, but 
with an odd number of steps. Class F is free of any parity restrictions. 
The allowable transitions between classes are then 


-> Or , Oo 

-»• Bi, 

Oo 

-> F. 

Oo ~ > Co, Oo — > 

0i — >■ Oo 

0i — > 

Bo 

, 0j 

—• * F, 0i — t C 0 ; 

F 

->■ F, 

F - 

t C 0 , 

F ->• C i; 


B„ -)■ 

Bi, 

Bo 

— * Ci; 


Bi -> 

Bo, 

Bi 

—t Co; 


Cq — > 

Ci; 

Ci 

— > Cq. 


Notice that the transition 0j — > Cj is illegal: Open tours of type (1) 
above use a transition Oo — ■> Ci or 0j — > Co when the endpoints appear, 
but tours of type (2) must use 0 o ->■ C 0 . Type (3) tours go in some 
fashion from 0 to F to C; type (4) tours go from 0 to B to C. Euler’s 
3x4 tours go 0 0 ->• B : -> B 0 -» B x C 0 , 0 0 -» Cj -4 C 0 -> Ci -4 C 0 , 
and 0 0 — >F— >F— >F— >Co, respectively. 

It turns out that a total of (84, 75, 204, 110, 72, 91, 76) vertices belong 
to the respective classes (0 0 , 0i, F, B 0 , B lt C 0 , Cr) in K. 

Computing the Parity 

There’s a systematic way to determine the class of any vertex directly 
from its state code, although the rules are slightly intricate. Given the 


519 


Long and Skinny Knight’s Tours 

values of mate[x\ for 1 < x < 7, where ‘7’ stands temporarily for ‘on’ in 
this discussion, we define several related quantities as follows: 

zq = the number of nonzero x with mate [x] = 0 and x even; 
zi — the number of nonzero x with mate[x\ = 0 and x odd; 
fo — the number of nonzero x with mate [x\ = x and x even; 

/ 1 = the number of nonzero x with mate [x] = x and x odd; 

Poo = the number of x < y with mate [x] = y, x and y both even; 

Poi = the number of x < y with mate[x\ = y, x + y odd; 

Pn — the number of x < y with mate [x] = y, x and y both odd. 

The values of fo and fi are redundant, because we clearly have 

z o + fo + 2poo + Poi =3, Z\ + /i + poi + 2pn = 4. 

The latter relations show that poo < 1 and pn < 2; both of these upper 
bounds are achieved in state 7650321 (that is, co65032l), which is the 
lexicographically largest state of K. 

How do these quantities change when a knight move between an 
even cell x and an odd cell y changes the mate table? If x and y were 
previously untouched, such a move clearly sets 

fo fo ~ 1) h <— fi ~ 1) Poi Poi + 1- 

If only one was untouched, one of four possible changes will occur: 

either f 0 fo - 1, zi <- z i + 1, p 00 «- poo + 1, Poi «- Poi - 1; 

or fo <— fo ~ 1) z i z i + 1, Poi t— poi + 1, pn <— pn — 1; 

or fi <— fi — 1, zo 4— zo + 1, Poo Poo — K poi <— poi + 1; 

or fi <— fi — 1, zo Zo + 1, poi <— Poi — 1, Pn Pn + 1- 

And if both were previously mated with other elements, we’ll have 

either z Q <- z 0 + 1, z x <- z x + 1, p () i <- p 0 i - 1; 
or zo <— zq + 1, Z\ <— Z\ + 1, poo t— Poo — L 

Poi t- Poi + 1, Pn t- Pn - 1- 

Notice that in each of these cases, the knight move leaves the quantity 
I = Zo — Zi + Poo — P 11 

invariant. Intuitively, I represents the difference between the number of 
even and odd cells covered in the first k — 2 columns. 


520 Selected Papers on Fun and Games 

When k increases by 1, we promote cells {l, . . . ,7} to {4 10}; 

promotion causes even and odd cells to switch roles, so we have 

z o z u Poo <-> p n, and I < 1. 

Then we append {1,2,3}, causing / 0 <-/ 0 + 1, + 2; now 

z o + fo + 2poo + Poi = z i + fi + Poi + 2pn = 5. 

(At this point ’oo' is temporarily represented by the even value TO’.) The 
value of I remains invariant while we do further knight moves, but it 
changes again when we truncate the tableau by removing the zero mates 
of {7, 8, 9}; truncation causes z 0 4- z 0 - 1 and z\ 4- Zx - 2, if the mate 
of cd isn’t 0, hence I 4—7+1. 

II oa was mated to oo before and after such a state transition, as it is 
in the 0 states, the net effect is to set 7 4—1 — 7. Therefore we see that 
the open states of class 0 () have 7 = 0, while those of class 0i have 7=1. 

If oo was mated to 0 before and after a state transition, as it is in the 
C states, the truncation operation causes z 0 4— z 0 - 2 and Zi 4 - z x — 1, 
hence 7 4— —1 — 7. In this case therefore we find that subclass C 0 
corresponds to 7 = —1 and subclass Ci corresponds to 7 = 0. (And we 
also see that a state code like 1035400, which makes 7 = +1, cannot be 
valid in K , thereby confirming a remark made above.) 

On the other hand if oo was mated to any of the other cells { 1, .... 6} 
before and after the transition, as it is in the F and B states, the process of 
demoting 10 to 7 has the effect of decreasing 7 by 1 , because it either sets 
Poi Poi - 1 and p n 4- p n + 1 or p Q1 4 - p 01 + 1 and p 00 4 - p 00 - 1. Thus 
7 always becomes simply —7 during an F or B transition. By looking 
at boundary conditions, we conclude that the bound states of class B 0 
are characterized by 7 = -1, while those of class Bj have 7 = +1. For 
example, the states of Euler’s tour T can be classified as follows: 
state zq zi f 0 fi p 00 p 01 p n 7 class 

OOOOOOoo 3 3 0 1 0 0 0 0 0 0 

1 m30002 2 1 0 2 0 1 0 +1 Bj 

6243ool5 0 0 1 0 0 2 1 -1 B 0 

oo060531 2 0 0 1 0 1 1 +1 Bj 

0000000 34000 0 0 -1 C 0 

Cycles 

The digraph K contains four 1-cycles (arcs from a vertex to itself): 

302 103 

02co0503 — y 02oo0503, oo200501 — y oo200501. 

031 230 

10430oa6 — y 10430oo6, 603oo014 — y 603co014. 


Long and Skinny Knight’s Tours 521 

They give rise to repetitive 3 x n knight’s tours for all n > 11, because 
we can loop around the cycle as many times as we like, producing a nice 
"hookwork” motif once we’ve set up a proper start and finish: 



All four of these 1-cycles yield essentially the same pattern, but reflected 
horizontally and/or vertically. 

Of course 1-cycles can appear only on a vertex whose state is F, be- 
cause the other kinds of states are bipartite and have only even cycles. 
The 2-cycles are, however, interesting too, both visually and mathemat- 
ically. There are 21 of them, giving rise to five distinct textures: 



The last of these was apparently first discovered by George Jelliss [5], 
who calls it “barbed wire.” It illustrates an interesting phenomenon: 
The 2-cycle pattern that we see is really the repeating sequence of tran- 
sitions 111, 222, 111 , 222, ..., not the 2-cycles of connectivity states 
that are tracked in K. Indeed, this sequence of transitions arises not 
only in the 2-cycle 

111 222 

®543201 — > 56oo0123 — > co543201 , 


522 Selected Papers on Fun and Games 

and in the top-to-bottom reflection of that cycle, 

222 111 

65oo0213 — > m452301 — > 65oo0213, 

but also in another 2-cycle that is its own reflection: 

111 222 

m325401 — > 21m0653 — > ra325401 . 

Moreover, in the symmetric tour illustrated above, it actually occurs in 
a 4-cycle of K, not a 2-cycle, namely 

111 222 111 222 

3col5402 — > 21600)53 — > 21co5403 — > 21503o)6 — 3ool5402 ! 

Hmm. If visual 2-cycles can occur in 4-cycles, perhaps there also are 
visual 1-cycles that don’t show up in any of K's 1-cycles. Sure enough: 
There’s a 3-cycle 

320 320 320 

0m30652 — > 0630oo25 — > 05302co6 — > 0 cd30652 

in which all transitions are 320, yet no 1-cycle has this property. Using 
this cycle, a knight can trace out a “latticework” path 



in which it covers just one third of the texture on each pass, as it travels 
right-left-right (starting at the left). 

And that’s not all. The digraph contains three different 5-cycles in 
which all of the transitions are 121 — thereby leading, in fact, to a family 
of symmetric knight’s tours in which all but seven of the transitions are 
121, whenever n mod 5^2: 







Jelliss has called this texture “brickwork” [5]; it goes right-left-right-left- 
right. Together with the hookwork and latticework motifs, it completes 
the set of visual 1-cycles possible with a 3 x n knight. 

Pleasant visual 3-cycles arise also from the 3-cycles of K that don't 
make the latticework pattern above: 



Long and Skinny Knight’s Tours 523 



One can well imagine the walls of a mathematics common room being 
graced with patterns like these. 

And K contains a vast number of 4-cycles and 5-cycles. Here are 
just a few snapshots of this mostly unexplored terrain: 






The second of these visual 4-cycles actually occurs in K only as a 12- 
cycle. Further study of such patterns is clearly indicated. 

Enumeration 

Our main goal, to count all tours of length 3n, is getting closer, now 
that we’re familiar with the digraph K. Let N(a,(3,n) be the number 
of paths of length n in K from state a to state j3 ; the number of 3 x n 
knight’s tours is then N(<j oy T,n) for open tours and JV(ct c ,t, n — 1) for 


524 Selected Papers on Fun and Games 

closed tours. (Strictly speaking, we really mean “walks” of length n, not 
“paths,” using the terminology of modern graph theory, because we’re 
talking about sequences 


a — ao — > ai — )• > a n — /3 

that might pass through the same state many times. But we will con- 
tinue to call them paths in this informal discussion.) 

In principle, the calculation of N(a, 0, n) is not difficult when n isn’t 
too large. We can set up, or imagine, K's adjacency matrix A, which 
has one row and one column for each state of K. The entry A a/3 in 
row a and column (3 is 1 if a — > 0 and 0 otherwise; symbolically we 
write A a p = [a — >0}. Then 

N{a,0,n) = A n afi 

is the entry in row a and column 0 of the nth power of matrix A. 

Instead of evaluating N(a , /3, n ) for a particular n, we can get much 
more information by determining the generating function 

G(a,f3) = N(a,0,O) + N(a,0,l)z + N(a,0,2)z 2 + ■ ■ ■ 

OO 

= ^IV(a,/3,n)A 

n—0 

which represents all of the N(a,0,n) simultaneously. The formula 
N(a, 0,n) = tells us that the matrix of all these generating func- 
tions is 


/ + Az + A 2 z 2 + = (I-Az)-\ 

n = 0 

where I = A 0 is the identity matrix whose entries are / a/3 = [a — 0]. 
Thus everything we want to know appears in the inverse of the ma- 
trix I - Az. The individual entries of this inverse are well known to be 
±g{a,/3,z)/f(z), where f{z) is the determinant of I - Az and g(a,fi,z) 
is the determinant of the submatrix obtained by deleting column a and 
row 0. Since f(z) and g(a,0,z) are polynomials in z, the generating 
functions G(a, 0) are rational, and the numbers N(a, 0 , n) obey a linear 
recurrence relation with constant coefficients. 

Thus everything works out swimmingly in theory. But in practice, 
we have to deal with the fact that A is a great big matrix with 712 
rows, 712 columns, and 5506 nonzero entries (about 7.7 nonzeros per 


Long and Skinny Knight’s Tours 525 

row). The polynomials f(z) and g(a,/3,z) have large degree and large 
coefficients. Dealing with giant matrices of polynomials is no picnic. 

We’re really interested only in two of those generating functions, 
however, namely G(a 0 ,r) and G(<t c ,t); so we don’t need all 712 2 = 
506,944 entries of the matrix (I — Az ) -1 . Our problem can be solved 
more economically by considering, say, the 712 generating functions 
G(a) = G(o,t), which satisfy the simultaneous linear equations 

G{a) = [a = r] + 2 G(/ 3) 

a— >(3 

over all vertices a of K. For example, the equation 

G(0oo00002) = z(G(1230oo05) + G(1250300) + G(5230100)) 

expresses the generating function for 0m00002, a B 0 state, in terms of 
the generating functions for a EL state and for two Ci states. 

The symmetry of K that takes a a' when the board is reflected 
about a horizontal axis now helps a lot, because we have a — > (3 if and 
only if a' — >(3' . Thus G(a) = G(a'), and the number of unknown func- 
tions is roughly halved; it decreases from 712 to 376. (In fact K has 40 
self-dual states with a = a'- examples are 321050m, 6043ml5, 3ool0502, 
and 4561230 of classes 0, F, B. and C, respectively.) We can treat the 
pair {a, a'} as a unified state, and the equation above simplifies to 

G(0m00002) = r(G(1230m05) + 2G({1250300, 5230100})). 

Further reduction occurs whenever we have two reduced states with 
exactly the same successors, because their generating functions are ob- 
viously identical. Mathematically speaking, we can let a = f3 be an 
equivalence relation between states with the property that, if a = f3 and 
if a has the successor states oq, . . . , a s while (3 has the successors /3±, 
. . . , /?t, then s = t and we have aq = /?i, . . . , a t = /3*- Such a relation 
implies that G(a) = G(/3) whenever a = f3. This idea reduces K to 
its “homomorphic image,” which is the multidigraph K = A'/= whose 
vertices are the equivalence classes [a]. 

The successive grouping of states with the same successors, after 
we’ve paired each a with its dual a ' , leads to an equivalence relation with 
just 220 inequivalent “superstates,” and 1648 arcs between them. For 
example, 3210000,5200100,0250300 is a superstate of three equivalent 
vertices of class Co; another superstate, 02435co6,42015oo6,026oo534, 
620m514, groups foiir of class B 0 ; the still larger example 


30100oo6 , 50001oo6 , 005oo304 , 500ml04 , 00503oo6 , 301co004 


526 Selected Papers on Fun and Gaines 

groups six of class F. There are five superstates of size 8, and there’s 
even a superstate of size 9. We’re making progress. 

The structure of K, in which vertices of classes F and B are indepen- 
dent of each other and come “between” those of classes 0 and C, helps 
further, and so does the bipartite nature of classes 0. B, C. The reduced 
digraph A has just (25,27,58,29,29,25,27) superstates of classes 0 0 , 
0i, F, B 0 , Bi, C 0 , Ci, respectively. 


Enumeration of Closed Tours 

All successors of C vertices are again of class C, so we can find the 
generating functions G{a) for all closed superstates a by solving 25 + 
27 simultaneous linear equations. This part of K is bipartite, so we 
immediately can reduce to just 25 equations, one of which is simply 
“G(t) = 1. The other 24 equations for vertices of class C 0 have a 
factor of z 2 on each right-hand side. Hence the solutions G(a) will each 
have the form g(a, z 2 )/P(z 2 ), where P is a polynomial that captures the 
"looping” structure of closed states. That polynomial P turns out to 
have degree 21: 

P(z) = 1 - 6z - 64z 2 + 200s 3 + lOOOz 4 - 3016z 5 - 34882® + 24256z 7 

- 237762 s - HMI682 9 + 2034082 10 + 1847042 11 - 44339‘2z 12 

- 143362 13 + 151296z 14 - 145920z 15 + 263424z 16 - 3174402 17 

- 368642 18 + 9666562 19 - 573440z 20 - 13 1 072 2 21 . 


The initial state a c — 1230000 is of class Ci. It has only one succes- 
sor, 6243510, which of course has class Co- The numerator polynomial 
(7(6243510,2) turns out to be 

16(z 4 + 5z 5 - 34z 6 - II62 7 + 5052 s + 6I62 9 - 31792 10 

- 4z 41 + 9536z 12 - 81762 13 - 13392z 14 + 15360z 15 + 13888z 16 
+ 2784z 17 - 3328z 18 - 2201 62 19 + 5120z 20 + 20 48z 21 ); 


we get the generating function for closed 3 X n tours by (i) multiplying 
3(6243510,2) by 2, (ii) dividing the result by P{z), and (iii) replacing z 
by z 2 . This process yields a power series that begins as follows: 

16z 10 + 80z 12 - 544z 14 + O(z 16 ) 10 19 

r r 62 2_ 64,4 + 0^6) - 16z 10 + 176z 12 + 1536z 14 + 0(z 16 ). 


There are 16 closed tour diagrams on a 3 x 10 board, 176 on a 3 x 12, 
1536 on a 3 x 14, and so on. Everything checks out. 

(■ Historical note: Noam Elkies and the author derived this gener- 
ating function independently in 1994; see [3] and the addendum below.) 


Long and Skinny Knight’s Tours 527 

These counts don’t take any account of symmetry, however, as men- 
tioned before. The 16 tours on the 3 x 10 have 16 different diagrams; but 
if we prefer to believe that reflection and/or rotation don’t really change 
a tour, each tour has been counted four times if it has no symmetry, twice 
if its diagram is the same under reflection or 180° rotation. It turns out 
that there are six geometrically distinct closed tours on this board, two of 
which have left-right symmetry, two of which are rotationally symmetric, 
and two of which have no symmetry at all (thus 16 = 2-2 + 2- 2 + 4- 2): 






The first of these is Bergholt’s original solution shown earlier; he subse- 
quently, on 24 August 1917, found the one directly below it [2], The two 
examples in the second line are in fact obtainable from those on the first 
line by flipping the moves on the left half of the board, top-to-bottom. 

Let’s try therefore to figure out exactly how many symmetric tours 
are possible. The necessary information is, in fact, already present in K, 
once we figure out how to access it. 

First let’s review the possibilities for symmetry in closed knight’s 
tours, as presented for example in [7] or [9] . When specialized to 3 x n 
boards, the theory tells us that three kinds of symmetry can occur: 
(A) reflection about a vertical axis; (B) rotation by 180°, causing the 
tour to reverse its direction; and (E) rotation by 180°, causing the tour to 
retain its direction. For convenience we’ll call them Axial, Bergholtian, 
and Eulerian. Types (A) and (E) are possible only if n/2 is odd. 

The closed states of K tell us the essential facts about “who is 
connected to whom” after we’ve made a partial tour covering k columns 
of the board. Most of those states are incompatible with any of the three 
symmetries, when we try to interface them with their mirror image or 
with their 180° rotation. 

Axial symmetry, for example, requires the cells that we’ve called 
1 through 6 to meet their reflected counterparts l' through 6' in the 


528 Selected Papers on Fun and Games 

center of the board, in the following mirrorlike pattern: 

4 1 1' 4' 

5 2 2' 5' • 

6 3 3' 6' 

Consider a more-or-less random closed state, say 6432510. It says that 
there have been knight moves that connect 1 with 6 and 2 with 4, while 
leaving 3 and 5 untouched; the mirror image will therefore connect 1' 
with 6' and 2! with 4' , while leaving 3 ; and 5' untouched. Since 3 is 
untouched we will need the future knight moves from l' to 3 and 5' to 3. 
By symmetry we’ll then have 3' to 1 and 3' to 5 as well. Since 5 was 
untouched, the move from 1' to 5 is forced too; but that’s impossible, 
because l' is already covered. 

On the other hand the somewhat similar state 6530210 does allow us 
to attain type (A) symmetry: Previous knight moves connect 1 with 6, 
connect 2 with 5, leave 3 untouched, and cover 4. The mirror moves will 
connect l' with 6', connect 2! with 5 r , leave 3' untouched, and cover 4' . 
A full tour is obtained if we now supply additional moves from 1' to 3. 
S' to 3, 2! to 6, 3 1 to 1, 3' to 5, and &' to 2. 

That same state leads to Bergholtian symmetry as well, using the 
picture 

4 1 3' 6' 

5 2 2' 5' ; 

6 3 1' 4' 

in this case the necessary and sufficient hookups are 3' to 3, 5' to 3. 2' 
to 6, 1' to 1, 3' to 5, and 6' to 2. 

Similar analysis shows that just 23 of the closed states support sym- 
metry. They fall into three categories, 

51 = {0050300,2143500,2160530,4321500,5000100,6320510}; 

5 2 = {1320650, 1325400, 1543200, 1560230, 

2130650, 2135400, 3010000, 4531200, 6530210}; 

5 3 = {1243650, 1265430, 2143000, 2160030, 

4231650, 4321000, 6235410, 6320010}. 

Axial symmetry comes from Si and S 2 ; Bergholtian symmetry comes 
from S 2 and S3 ; Eulerian symmetry is rarer, it comes only from Si . The 
states of Si and S 2 belong to class Ci, so we reach them only when k 
is odd, as required for symmetry types (A) and (E). The states of S 3 
belong to class C 0 , so we reach them only when k is even. (When state a 
belongs to Sj, so does its dual, a'; the state 3010000 in S 2 is self-dual.) 


Long and Skinny Knight’s Tours 529 

Let A c (z), B c (z), and E c (z) be the generating functions for the 
number of ways to complete half of a knight’s tour that has symmetry 
of types (A), (B), or (E), respectively. Then 

A c (z ) = z G(a c , a) = 4z 5 + 24z 7 + 276z 9 + 0(z n ); 

aE5iU52 

B c (z) = z G(cr c , a) = 4 z 5 + 8 z 7 + 48 z 8 + 152z 9 + 352z 10 + 0(z n ); 

aeS2US 3 

E c (z ) = z G(cr c ,a ) = 16z 7 + 124z 9 + 0(z 11 ). 

a£S i 

The enumeration of symmetric closed tours will be complete if we just 
compute the generating functions G(<r c ,a) for the 23 special states a. 

Our calculations above were designed to compute the generating 
functions G(a) = G(a, r) for paths from a to the sink; unfortunately 
those functions aren’t what we need here. Our new problem counts 
paths to a from a source , so the paths should go the other way. The same 
methods apply however, when all arcs of K are reversed, except that the 
reduced multidigraph turns out to be somewhat larger in this case than 
it was before. The denominator, P(z 2 ), remains the same, because the 
determinant of a matrix doesn’t change when we transpose the matrix. 

Thus we obtain three magic polynomials 
a c (z) = 4 z 5 - 124z 9 + 212Z 11 + 1248z 13 - 5120z 15 - 4928z 17 

+ 41280z 19 + 22224z 21 - 140608z 23 - 15 1 680z 25 + 189 9 52z 27 
+ 413056z 29 - 50 4 32z 31 - 121344z 33 - 141312z 35 - 33 7920z 37 
+ 49152z 39 + 163 8 40z 41 + 65536z 43 , 

b c (z) = 4z 5 - 16z 7 + 48z 8 - 152z 9 + 64z 10 + 576z 41 - 1432z 12 
+ 1584z 13 - 672z 14 - 5816z 15 + 15792z 16 - 2928z 17 

- 6864z 18 + 14832z 19 - 65232z 20 - 23 5 84z 21 + 79776z 22 

+ 70944z 23 + 95 9 36z 24 + 7 1 552z 23 - 28 6 8 48z 26 - 395648z 27 

- 31104z 28 - 22016z 29 + 36 2 752z 30 + 53 8 8 80z 31 + 156160z 32 
+ 107520z 33 + 88576z 34 - 96 2 56z 35 - 22 5 2 80z 36 - 24 9 8 56z 37 

- 454656z 38 - 311296z 39 + 196 6 08z 40 + 29 49 1 2z 41 + 65536z 42 , 

e c (z) = 16z 7 + 28z 9 - 364z 41 - 336z 13 + 696z 15 - 2000z 17 

+ 26448z 19 + 45808z 21 - 211552z 23 - 2 2 3 2 32z 25 + 58 5 6 00z 27 
+ 435072z 29 - 58 93 1 2z 31 - 228864z 33 - 45 0 56z 35 - 88 0 64z 37 
+ 360448z 39 - 13 1 072z 41 + 65536z 43 , 

where A c (z) = a c (z)/P(z 2 ), B c (z) = 6 c (z)/P(z 2 ), E c (z) — e c (z)/P(z 2 ). 


530 Selected Papers on Fun and Games 

Enumeration of Open Tours 

The 220 x 220 adjacency matrix for K has the somewhat sparse form 


0 

c 

F 0 

0 

£h 

Xo 

w 

c 

0 

F 1 

b 2 

0 

*2 

0 

0 

0 

F 

0 

0 

Fo 

Fi 

0 

0 

0 

0 

B 

0 

B\ 

0 

0 

0 

B 

0 

b 2 

0 

0 

0 

0 

0 

0 

0 

C 

0 

0 

0 

0 

0 

C 

0 


We’ve seen how to find the generating functions G(a) for the “C” part 
of this matrix, at the lower right corner; each of them has the form 
g(a)/P( z2 ), where g(a) = g(a,z ) is a polynomial in 

The “I?” part of this matrix leads, similarly, to generating functions 
G(a) of the form g(a)/Q(z 2 ) for superstates a of class B, where 

Q(z) = 1-4 z - 26z 2 + 4 z 3 - 43 z 4 - II 62 5 + 8882 ® + 1224s 7 

+ 10292s 8 + 6052s 9 - 7088s 10 + 111280s 11 - 16192s 12 

- 204080s 13 + 407232s 14 - 681472s 15 + 66432s 16 

- 699392s 17 - 943104s 18 - 126976s 19 + 98304s 20 . 

This polynomial Q is based 011 the submatrices B and B, which govern 
the interactions between superstates of classes B 0 and Bi, just as P was 
based on the analogous submatrices C and C for superstates of classes 
Co and Cj. The numerators g(a ) in this case are not, however, simply 
polynomials in 2 ; they have the form 

5(a) = ^< 7 q/ 3 G(/ 3 ), summed over all 8 of class C. 

P 

Here the coefficients g a p are polynomials in 2 that depend on the sub- 
matrices B 1 and B 2 , which govern the transitions from B superstates to 
C superstates. We’ve already determined the generating functions G(/3) 
for the C superstates /3; so we obtain G(a) for each B superstate a by 
plugging in the known values G(/3), yielding a rational function with 
denominator P(z 2 )Q(z 2 ). 



Long and Skinny Knight’s Tours 531 

The U F ” part of A is similar, but more complex because it’s not 
bipartite. When superstate a has class F, its generating function G(a) 
has the form g(a) / R(z), where R{z) comes from the 58x58 submatrix F: 

R{z) = 1 — 3z — 9z 3 — 14z 4 + 61z 5 + 110z 6 + 61z 7 — 35z 8 

- 498z 9 - 1262z 10 - 356Z 11 + 3864z 12 + 3788z 13 - 6008z 14 

- 2472z 15 - 7532z 16 - 17956z 17 + 17732z 18 + 36088z 19 

- 35176z 20 + 2256z 21 + 154624z 22 + 109008z 23 + 73376z 24 

+ 71440z 25 - 104 3 36z 26 - 762592z 27 - 277728z 28 - 123 0 08z 29 

- 573760z 30 - 77 1 456z 31 + 221568z 32 + 122 3 68z 33 - 1205760z 34 

+ 1966592z 35 + 7 1 4752z 36 - 25 5 5 9 04z 37 - 412672z 38 + 13 762 56z 39 

- 272384z 40 - 29 49 1 2z 41 + 1781760z 42 + 860 1 60z 43 + 5 1 60 96z 44 

+ 1081344z 45 - 65 5 36z 46 - 262144z 47 + 131072z 48 . 

Again g(a) = g a gG(/3), summed over all /3 of class C, but with poly- 

nomial coefficients g a p this time coming from submatrices Fq and Fj. 
Thus the denominator for the rational generating functions G(a) is 
P(z 2 )R(z), when a is an F state. 

Finally we come to the top rows of matrix A, which correspond 
to paths from states of class 0. The submatrices C and C for 0-t.o-0 
transitions are the same as those for C-to-C transitions; hence the fac- 
tor l/P(z 2 ) that corresponds to cycles between C states arises also for 
cycles between 0 states. We conclude that the generating function for 
any 0 state a has the form g a gG(l3) / P(z 2 ), summed over all super- 

states /3 of classes F, B, and C, which we already know. 

Let’s divide all open knight’s tours into three main categories: 

• Type X have both endpoints in the same column. 

• Type F have endpoints that match the nearest corner cells. 

• Type B have endpoints that don’t match the nearest corner cells. 
(Types F and B have endpoints in different columns. Cells “match” if 
they are both even or both odd - that is, if they have the same “color” 
on a chessboard.) For example, the 3x4 tours at the beginning of this 
chapter have types B, X, F, respectively. These three basic types are 
just the same as the four considered earlier with respect to parity, except 
that the tours that we previously called types (1) and (2) are both just 
type X, but distinguished by whether the board has an even or odd 
number of columns. Our previous types (3) and (4) are now called F 
and B, respectively. The corner cells of boards with an even number 


532 Selected Papers on Fun and Games 

of columns are even at the left and odd at the right; otherwise all four 
corner cells are even. 

We obtain all open tours of type X by zeroing out all of the F 
and B submatrices of the big matrix A. The generating function for 
all X tours is therefore x 0 (z)/P(z 2 ) 2 = 4z 4 + 80z 8 + 0(z 9 ), for some 
polynomial x 0 (z). Similarly, we get all open tours of type F by ze- 
roing out the B and X submatrices, obtaining a generating function 
fo{ z )/{P(z 2 )R(z)) = 2z 4 + 52z 7 -)-224z 8 -|-0(z 9 ) for another appropriate 
polynomial f 0 (z); and the generating function b 0 (z 2 )/(P(z 2 )Q(z 2 )) = 
2 z 4 + 92z 8 + 0(z 10 ) for open tours of type B results when the F and X 
submatrices are zeroed. The sum of all three generating functions is 
to(z)/(P(z ) Q(z 2 )R(z)) = 8z 4 + 52z 7 + 396z 8 + 0(z 9 ), the generating 
function for open tours of all three kinds. This function solves the enu- 
meration problem that we set out to tackle, because it enumerates the 
diagrams of open tours on 3 x n boards for all n. 

There’s no point in wasting paper by listing the polynomials x 0 (z), 
fo(z), b 0 (z), and t 0 (z) here, although curious readers can find them 
in [10]. Let us, however, go on to enumerate the symmetrical open 
tours, so that we can determine exactly how many of the knight’s tour 
diagrams are essentially distinct. 

Symmetrical open tours exist of all three types X, F, and B. We’ve 
seen the smallest examples for F and B, found by Euler, on the 3x4 
board; the smallest examples for type X appear on the 3x9: 


In general, the only possibility for symmetry of an open tour is analo- 
gous to Bergholt.ian symmetry of a closed tour, where rotation by 180° 
yields the same diagram but causes the tour to run backwards. We can. 
in fact, obtain a symmetric open tour by removing either of the edges in 
the X that appears at the middle of any closed tour with Bergholtian 
symmetry; this open tour will be of type F if n/2 is odd, type B if n/2 
is even. For example, here are the 3x 10 open tours of this type: 




Long and Skinny Knight’s Tours 533 


To enumerate open tours that are symmetrical on 3 X n boards, when 
n is even, we can therefore proceed as we did for Bergholtian symmetry of 
closed tours, by characterizing the states that will support 180° rotation 
after n/ 2 steps. Euler’s first tour, for example, reaches state 6243ool5 
after two steps; and any ?r/2-step path from cr 0 to 6243ml5 in K will 
yield a symmetric 3 x n open tour if the next transition is 131. This open 
tour will be of type B, and n will be a multiple of 4, because 6243ool5 
belongs to class Bo. 

The open tours that are symmetrical on 3 X n boards for odd values 
of n can be characterized in essentially the same way, but the configu- 
ration of cells near the center now looks like this after (n — l)/2 steps: 

4 1 0 3' 6 ' 

5 2 0=0' 2' 5' 

6 3 1' 4' 

Consider, for instance, state 3412oo05, which means that the knight 
moves within the first (n — l)/2 columns connect 1 with 3, 2 with 4, 
and 5 with oo. while covering 6 . Let’s continue by connecting 0 with 4 
(and also with 4', since 0 = O'); that’s the only way to connect 4 to the 
future. We now must choose two neighbors of a, and the corresponding 
two neighbors of a'; and we’ll also have to move from either l' or 3' to 2, 
hence from 2 ' to either 1 or 3. Say we move 2 ' to 1 ; then @ must move 
to 3 and also to either 5 or 5'. Both of those setups work. So do the 
alternatives with 2 ' to 3, a to l', and 8 to either 5 or 5'. Thus there are 
four different ways to get a symmetric 3xn tour, when state 3412oo05 
has been reached after the first ( n — l )/2 columns. 

State 6 OOOOI 00 is another instructive case. To make a symmetric 
3 x n tour after (n — l)/2 steps have led to this state, we’ll need to 
connect 0 to 6 and 6 ', a' to 1 and oo, 8 to l' and oo'. The resulting tour is 
of type X. Further study of this situation shows that state 600001oo and 
its dual, 004300m, can arise only when the the self-dual state 604351m is 
followed by transition 133 or 332. Furthermore, every closed tour ends 
when the self-dual state 6043510 goes to 0000000 with transition 333. 
Therefore every closed tour of the 3 x n board leads to two open tours of 
type X on the 3 x (2n+l) board, one that passes through state 600001m 
and another that passes through state 004300m. Applying this construc- 
tion to Bergholt.’s first 3 x 10 tour yields an open tour with reflective 
symmetry in each half, in addition to overall rotational symmetry: 


534 Selected Papers on Fun and Games 


Table 1 . States after 3 x n/2 that yield symmetry on 3 x n 


OO00OOO3 

15002oo6 

2160oo35* 

423150)6 

50)60132 

0)325401 

05302oo6 

150o)204 

21oo0653 

4321oo05* 

6230)514 

0)543201 

053oo204 

loo00652 

210054O3 

45ool203 

6320ool5* 

0)560231 

Class F 

0oo30652 

loo05402 

35102od6* 

40)51302 

65oo0213 

00)35402 

214300O5* 

351oo204* 

53201oo6 

6oo50312 

12435006 

215030)6 

3001O652* 

53200104 

ooOOOOOl 

126oo534 

2150)304 

3col5402* 

5oo43102 

0)320651 




Class Bo 




02354o)6 

0230)654 

03200oo6 

032a)004 

0oo43002 

0oo60032 

12054oo6 

12000654 

21000oo6 

210oo004 

32154006* 

3210)654* 

42001653 

4oo01002 

524310)6 

62430015* 

62500314 

620)5413 

6o)00012 

00243651 

00265431 




Class Bi 




0030o)05 

1000oo05 

13205oo6 

132oo504 

100435O2 

loo60532 

21305oo6 

213oo504 

3010oo05* 

400315O2 

50o)0103 

60)30512 

0)050301 



* = times 2 


Table 2. States after 3 x (n — l)/2 that yield symmetry on 3 x n 


Class Do 


000065oo* 

000540oo* 

004300CO 

006003a) 

043200a) 

045230a)* 

054320a)* 

056023O)* 

0560230) 

063002a ) 

065032a)* 

124300a) 

126003a) 

140200a) 

16OOO200 

214300oo 

216003oo 

341200oo* 

361002a)* 

400100a) 

423100a) 

42513O00* 

432100oo 

450120a)* 

524310a)* 

526013a)* 

540210a)* 

560012a)* 

600001CO 

623001a) 

625031a)* 

632001a) 

650021a)* 




Class F 


0043oo05* OO6O0035* 00000653* 
0 0)35402* 1243oo05* 1260oo35* 
1600co25* 16oo0023 la>00652* 

2160a>35* 21oo0653* 21a)5403* 
4001oo05* 40CD1003 4231a>05* 

54a>2103* 56oo0123* 5oo43102* 
632O0015* 65oo0213**6oo30012 
(B060031 0)230651* 0)235401* 

a)543201**O)560231**a)630021 


00oo5403* 0432a)05* 0630ai25* 0oo30652* 
12co0653* 12oo5403* 1402oo05* 14co2003 
loo05402* lco43002 loo60032 21430)05* 

341 2a)05** 36 10oo25**3oo 10652* *3oo 15402** 
4321oo05* 45oo 1203* *4oo3 1002 4o)51302* 

5oo60132* 6000a)15* 60oo0013 6230col5* 

6oo50312* a)000651* a)005401* o)043001 
00320651* 00325401* a>432001 oo452301* 

0)650321* 


* = times 2; ** = times 4 


A surprisingly large number of states can be extended after n 
columns to form symmetric open tours that have either 2 n columns 


Long and Skinny Knight’s Tours 535 

or 2 n + 1 columns or both. In fact, more than 1/4 of the non-C states 
of AT 143 out of 545 — have this extension property. They’re listed 
in Tables 1 and/or 2, together with the appropriate multiplicative fac- 
tors that should be used when counting symmetric diagrams of various 
kinds. From that information we can compute the relevant generating 
functions for symmetric open tours: 

X s (z) = zx s (z 4 )/P(z 4 ) = 4z 9 + 16z 13 + 264z 17 +0(z 21 ) for type X; 
F s (z) ~ f s (z)/(P(z 4 )R(z 2 )) = 2z 4 +4z 7 + 12z s +0(z 9 ) for type F; 

B s (z) = b s (z 2 )/(P(z 4 )Q(z 4 )) = 22 4 + 82 8 + 16z 10 + O(2 12 ) for type B. 

Again the polynomials x s , f s , b s can be found in [10]. 

Asymptotic Growth 

The number of 3 X n tours is huge even when n is fairly small, as we’ve 
seen for the case n — 100. And the form of the generating functions 
allows us to pin down the exact rate of growth for each of the species 
of tours that we’ve studied, because the coefficient of z n in 1 / f(z) has 
exponential growth rate p n when l/p is the smallest positive root of 
/(1/p) = 0, if / is a polynomial. 

The relevant values of p for the three polynomials P{z 2 ), Q(z 2 ), and 
R(z) are respectively 

p{P) = 3.11949 04567 55102 15858 14810 12447 09095 14449+ ; 
p(Q) = 2.73629 97867 23484 49801 18887 83106 50428 06057+ ; 
p(R) = 3.45059 2111750198 79034 91949 64004 51254 67975+ . 

(All three polynomials happen to be irreducible over the rational num- 
bers, so their roots are simple.) We may conclude that 

• Open tours of type F predominate, with approximately c F p(R) n 
tours when n is large, where c F zz 0.027892741. 

• There are approximately 0.000169np(P) ra and 0.00144np(F , ) n open 
tours of the respective types X and B, when n is even, and approx- 
imately 0.0000526np(T’) n of type X when n is odd. 

• Approximately 0.0001899p(P) n closed tours are possible, when n is 
a large even number. 

Symmetric tours are negligible by comparison, since there are only 
0(p(P)"/ 2 ) of them. 

When an open tour has endpoints in columns j and k, where 1 < 
j < k < n, let m — k — j. The number of open tours when m and 


Table 3. Exact counts for 3xn knight’s tours of various kinds 


536 Selected Papers on Fun and Gaines 



CD 

o 

04 

o 

CD 

04 

F 

F 

F 

04 

o 

rH 


ID 


b- 

05 

CD 

F 

F 

ID 

04 

F 


CO 


1—1 

rH 

04 

05 

ID 

b- 

00 





04 

ID 

05 

F 

05 


F 





CD 

i— l 

i—i 

rH 

F 


F 





CO 

04 

CD 

O 

00 


i 






F 

b- 

i— | 

04 








ID 

ID 

H 

04 









o 

04 

CO 









pH 


pH 

05 

o 

o 

O 

o 

o 

O 

F 

CD 

O 

O 

rH 







O 

b- 


00 








ID 

’ — 1 


CD 








CO 

o 


CO 








CO 

04 


ID 








CO 

F 


b- 








F 

i—i 


lD 









O 


O 









CO 


CO 


oo 

CD 

04 

F 

CD 

o 

CD 

00 

F 

oo 

00 

04 


ID 

04 

t- 

b- 

b- 

o 

O 

oo 


b- 

04 

rH 

1 — 1 

04 

o 

05 

o 

b- 

CD 







b- 

O 

00 

CD 

ID 


f 





co 

b- 

t- 


CD 


H 






04 

1—1 

F 

00 








ID 

1 — 1 

05 

ID 









00 

i-H 

O 











rH 

b- 

o 

O 

o 

o 

o 

o 

00 

F 

O 

04 

rH 1 







00 

o 


05 








F 

ID 


05 








ID 

ID 


o 








i—i 

00 


o 








F 

05 


F 









04 


CO 









04 


04 

CD 

F 

o 

00 

o 

F 

oo 

00 

04 

o 

o 

04 


F 


04 

CD 

O 

b- 

o 

00 


F 





00 

00 

F 

CD 

00 


ID 





CO 

co 

b- 

ID 

CD 


pH 






04 

04 

00 

CO 








ID 

CO 

b- 

CD 









CD 

H 

oo 

ID 

o 

o 

o 

o 

O 

O 

00 

CD 

o 

F 

rH 







O 

b- 


00 








04 

ID 


b- 








O 

00 


00 








F 

05 


CO 











oo 









pH 


1—1 

F 

CD 

F 

00 

CD 

F 

CD 

CD 

o 

CD 

04 

CO 

04 


rH 

04 

05 

ID 

o 


IH 


ID 





CO 

CD 

04 

F 

04 


rH 1 






00 

i-H 

CD 

CD 








F 

F 

»D 

F 









F 

rH 

CD 

CO 

o 

o 

o 

o 

O 

o 

F 

O 

o 

F 

i—* 1 







f 

04 


CD 








b- 

rH 


oo 








CO 

ID 


00 









04 


04 









rH 


tH 

<N 

CD 

o 

o 

o 

o 

F 

CD 

F 

oo 

00 

H 

b- 





F 

05 

04 

04 

F 


1— 1 






04 

O 

05 

04 








ID 

b- 

F 

r- 









co 

rH 

ID 

i— I 

o 

o 

o 

o 

o 

o 

04 

o 

o 

04 

rH 







ID 

04 


b- 








CO 

CO 


CD 









O 


O 









rH 


rH 

o 

CD 

F 

F 

o 

F 

CD 

00 

CD 

F 

00 

1— 1 

1“H 






CD 

pH 

CD 

F 








CO 

CD 

O 

O 









rH 

rH 

CO 

05 

o 

o 

o 

o 

o 

O 

o 

o 

o 

O 








F 

04 


CD 









ID 


ID 

oo 

o 

o 

o 

o 

o 

O 

O 

F 

04 

CD 








00 

04 

05 

05 









04 


CO 

b- 

o 

o 

o 

o 

o 

o 

O 

04 

O 

04 









ID 


ID 

CO 

o 

o 

o 

o 

o 

o 

O 

O 

o 

O 

ID 

o 

o 

o 

o 

o 

o 

o 

O 

o 

O 

F 

o 

o 

o 

o 

o 

o 

F 

04 

04 

00 

II 

II 

II 

II 

II 

II 

II 

II 

II 

II 

II 

£ 











£ 



JS, 




£ 




O 

u 


u 

Kl 

to 

o 

u 

0 

* 


0 

CQ 

Eh 


= 0 0 0 0 0 4 0 0 0 16 0 0 0 264 0 0 0 

F s [n] = 2 0 0 4 12 20 28 120 104 304 384 1304 1680 4936 5908 18304 21412 

B s [n] = 2 0 0 0 8 0 16 0 48 0 200 0 616 0 1832 0 6008 

T a [n\ = 2 0 0 2 10 12 22 60 76 160 292 652 1148 2600 3870 9152 13710 

G 0 [n] = 3 0 0 14 104 146 773 2698 14350 32296 161714 460022 2159794 5851548 26468357 76442996 330719293 


Long and Skinny Knight’s Tours 537 

n — m are both large is approximately proportional to p{P) n ~ m p{R) m 
for type F, p(P) n ~ m p(Q) m for type B. Since p(Q) < p(P) < p(R) we 
may conclude that most of the open F tours have endpoints near the 
left and right edges of the board, but most of the open B tours have 
endpoints near each other. 

Summary 

We have derived formulas that enable us to count the exact number of 
solutions to 15 different flavors of the 3xn knight’s tour problem: 

C[n] — closed tour diagrams; requires n mod 2 = 0. 

■A c [n] = closed tour diagrams with left-right symmetry; n mod 4 = 2. 
B c [n] = closed tour diagrams with Bergholtian symmetry; n mod 2 = 0. 
E c [n } = closed tour diagrams with 180° symmetry; n mod 4 = 2. 

C s [n ] = (7L c [n] + B c [n ] + E c [n])/ 2: distinct symmetric closed tours. 
G c [n\ = C[n]/ 4 + C s [ri\/ 2: geometrically distinct closed tours. 

X 0 [n ] = open tour diagrams of type X. 

F 0 [n\ = open tour diagrams of type F. 

B 0 [n] = open tour diagrams of type B; n mod 2 = 0. 

T[n\ = X 0 [n } + F 0 [n] + B 0 [n\. open tour diagrams. 

X s [n] = symmetric open tour diagrams of type X; n mod 4 = 1. 

F s [n ] = symmetric open tour diagrams of type F. 

-B s [n] = symmetric open tour diagrams of type B; n mod 2 = 0. 

T s [n ] = (V s [n] + F s [n] + B s [n})/ 2: distinct symmetric open tours. 

G a [n ] = T[n]/4 + T s [n]/2: geometrically distinct open tours. 

Values of these quantities for small n appear in Table 3; further 
values can be found in [10]. In each case we have obtained rational 
generating functions, from which the enumeration can be extended to 
arbitrarily large n without great difficulty. 

References 

[1] Ernest Bergholt, letter to the editor, British Chess Magazine 38 
(1918), 74. 

[2] Ernest Bergholt, “Memoranda on the knight’s tour,” edited by G. P. 
Jelliss from original notes written by Bergholt and sent to H. J. R. 
Murray in 1916 and 1917, The Games and Puzzles Journal 2,13 
(28 May 1996), 213-217; 2, 14 (16 December 1996), 231-237, 244. 

[3] Noam D. Elkies and Richard P. Stanley, “The mathematical knight,” 
The Mathematical Intelligencer 25, 1 (Winter 2003), 22-34. 


538 Selected Papers on Fun and Games 

[4] L. Euler, “Solution d’une question curieuse qui ne paroit soumise 
a aucune analyse, Memoires de 1 Academie Royale des Sciences et 
Belles-Lettres (Berlin, 1759), 310-337. 

[5] George Jelliss, “Open knight’s tours of three-rank boards,” Knight’s 
Tour Notes , note 3a (21 October 2000). Published online at 
http://www.ktn.freeuk.com/3a.htm (accessed April 2010). 

[6] George Jelliss, “Closed knight’s tours of three-rank boards,” 
Knight’s Tour Notes, note 3b (21 October 2000). Published online 
at http://www.ktn.freeuk.com/3b.htm (accessed April 2010). 

[7] George Jelliss, “Symmetry in knight’s tours,” Knight’s Tour Notes 
(2001). Published online at http : //www . ktn . f reeuk . com/sa . html 
(accessed April 2010). 

[8] Donald E. Knuth, Sorting and Searching, Volume 3 of The Art 
of Computer Programming (Reading, Massachusetts: Addison- 
Wesley, 1973). 

[9] Donald E. Knuth, “Celtic knight’s tours,” Chapter 41 of the present 
volume. 

[10] Neil J. A. Sloane, The On-Line Encyclopedia of Integer Sequences , 
http://www.research.att.com/~njas/sequences; see sequences 
A070030, A169696, and A169764-A169777 [accessed June 2010]. 

Addendum 

As mentioned above, Noam Elkies and I had already enumerated the 
Hamiltonian cycles of S n several years ago. In fact, we both did it during 
early April of 1994, although we were completely unaware of each other’s 
interest in the problem until we happened to meet at the Mathematical 
Sciences Research Institute a short time later(!). Noam beat me by a 
couple of weeks. He subsequently sent me his computer program, which 
used a state-transition scheme similar to the one described above. But 
actually he had a better idea: Instead of using a table of six mates — this 
was the case of closed tours, where m does not arise --he got by with 
only five, which he aptly called a “quincunx.” Indeed, my transition 
calculation 

41 741 041 41 

52 852 -t 052 52 

63 963 063 63 

with nine intermediate mates can be reduced via quincunxes to 

2 42 02 2 

531 7531 0531 >-> 531 , 

6 86 06 6 


Long and Skinny Knight’s Tours 539 

with only eight. More importantly, I see now that his scheme makes it 
easy to compute the right-to-left reflection of any transition; with my 
scheme I need to know two successive transitions q — > q' — > q" before I 
can reflect the transition q — > q' . 

Interested readers will probably find it instructive to enumerate open 
3 X n tours with Elkies’s quincunx strategy, by introducing the vertex oc 
as done above. 

Hopefully the results obtained with both methods will agree, as they 
did in the much simpler closed-tour problem. If not . . . , well, we’ll learn 
some more about debugging. 



Chapter 43 


Leaper Graphs 


[Originally published in The Mathematical Gazette 78 (1994), 274-297.] 

An {r, sj-leaper [15, page 130; 3, page 30; 16] is a generalized knight that 
can jump from ( x , y) to (x ± r, y ± s) or (x ± s,y ± r) on a rectangular 
grid. The graph of an {r, sj-leaper on an m x n board is the set of 
mn vertices (x,y) for 0 < x < m and 0 < y < n, with an edge between 
vertices that are one (r, sj-leaper move apart. We call x the rank and 
y the file of board position ( x , y). George P. Jelliss [9, 10] raised several 
interesting questions about these graphs, and established some of their 
fundamental properties. The purpose of this paper is to characterize 
when the graphs are connected, for arbitrary r and s, and to determine 
the smallest boards with Hamiltonian cycles when s = r + 1 or r = 1. 

Theorem 1. The graph of an {r, sj-leaper on an m x n board, when 
2 < m < n and 1 < r < s, is connected if and only if the following 
three conditions hold: (i) r + s is relatively prime to r — s; (ii) n > 2s; 
(Hi) m > r + s. 

Proof. Condition (i) is necessary because any common divisor d of r + s 
and r — s will be a divisor of x + y for any vertex (x, y) reachable from 
(0,0); any leaper move changes the sum of coordinates by ±(r + s) or 
±(r — s). If d > 1, vertex (0, 1) would therefore be disconnected from 
vertex (0,0). 

Condition (ii) is necessary because m < n < 2s would imply that the 
“middle” point ( |_m/2j , |_n/2j ) is isolated: We would have |_?n/2j — s < 0, 
[m/2j + s > m, \n/2\ — s < 0, and |_n/2j + s > n, leaving no place to 
leap from the middle. 

To show that condition (iii) is necessary we show first that the {r, sj- 
leaper graph on the infinite board with m = r + s — 1 and n — oo has no 
path from (0,0) to (0, 1). For this purpose we construct a special path 


541 


542 Selected Papers on Fun and Games 


through special points ( x k ,y k ) as follows: 

{ x o,Vo) = (r- 1,0) ; 


( x k+i ? Vk + l) 


(%k +r,y k + s), ifx k <s-l- 
( x k - s,y k + r ) , if x k > s . 


The path terminates when x k = s - 1. It is not difficult to see that ter- 
mination will occur when k = r + s — 2, because the sequence Xq, X \ , ... 
runs first through all values {0, 1, . . . , r + s — 2} that are congruent to 
-1 modulo r, then all values congruent to -1 - s, then all values con- 
gruent to —1 — 2s, etc. Since s is relatively prime to r, all residues will 
occur before we finally reach -1 - (r - l)s modulo r, which is the class 
of values congruent to s - 1. Now if (x,y) is any point reachable from 
(r — 1,0) on this infinite graph, there is a unique value of k such that 
x ~ x k . And the difference y — y k must be an even number, because all 
{r, s}-leaper moves preserve this condition. Therefore the point {x, y + 1) 
is not reachable from (r — 1,0). 

Condition (iii) is therefore necessary. Vertex (0, 1) will surely be 
disconnected from (0,0) on any m x n board with m < r + s if it is 
disconnected from (0,0) on a (r + s - 1) x oo board. 

Finally we show that conditions (i), (ii), and (iii) are in fact sufficient 
for connectivity. We need only prove that the graph is connected when 
m = r + s and n — 2s, because the connectivity of an m X n board 
obviously implies connectivity for (m + 1) x n and m x (n + 1) boards 
when m > 1. The proof is somewhat delicate, because the graph is, in 
some sense, “just barely” connected. 

Let m = r + s and n = 2s, and let t be any number in the range 
0 < t < n. Define a path on the m x n board by the rules 


i x o,yo) = ( 0 ,t ) ; 


[Xk+\ i yk+i 



(x fc + r, y k ± s ) , 
( x k ~s,y k ±r), 


if x k < s ; 
if x k > s. 


The sign of ±s is uniquely determined by the condition 0 < y k+1 < 2s; 
the sign of ±r may or may not be forced by this condition, and we can 
use any desired convention when a choice is possible. The path will reach 
a point ( x k , y k ) of the form (0, u ) when k = r + s, after doing s moves by 
(r, ±s) and r moves by (-a, ±r). Therefore (0, u) is reachable from (0, t); 
we want to use this information to establish connectivity of the graph. 

Consider first the case t — 0; we will choose the signs so that y k 
is either Oor r or s orr + s for all k. This produces a sequence of 
file numbers y ( k 0) . Similarly, we can keep y k in the set {0,r, s,r + s} 


Leaper Graphs 543 

whenever t = r, s, or r + s; this procedure defines sequences y]^\ y ^ 1 , 
;v[. r+5) . Now notice that after k steps we have x& — ar — bs for some 
uniquely determined a and b, where k = a + b, and the value of 
depends only on the parity of a and b: 


a 

b 

( 0 ) 

Vk 

( r ) 

Vk 

( 3 ) 

Vk 

(r+s) 

y k 

even 

even 

0 

r 

s 

r + s 

odd 

even 

s 

r + s 

0 

r 

odd 

odd 

r + s 

s 

r 

0 

even 

odd 

r 

0 

r + s 

s 


After r + s steps we have x r+s = 0 and a = s, b = r. Therefore 
if r is even and s is odd, we have found paths from (0,0) to (0, s) and 
from (0, s) to (0,0). Combining them into a cycle shows that (x,0) and 
(x, s) are reachable from (0, 0) whenever x is even. Similarly, the paths 
from (0, r) to (0, r + s) and back to (0, r) show that (x, r) and (x, r + s) 
are reachable from (0,r) whenever x is even. In the other case, when r 
is odd and s is even, the construction proves that (x, 0) and (x,r) are 
reachable from (0,0) whenever x is even, while (x, s) and (x,r + s) are 
similarly reachable from (0, s). The same argument establishes a more 
general principle, which can be formulated as follows: 

Lemma 1. Let t be any value such that 0 < t < t + r < s. Then (x, t) is 
reachable from (z, t ) on the (r + s) X 2s board and (x, t + r) is reachable 
from (z, t + r), whenever x — z is even. 

The proof consists of forming sequences y£\ y[* +r \ Vk +S \ and y[ t+r+s ' > 
as before. □ 

Our next step in proving Theorem 1 is to establish a mild form of 
connectivity: 

Lemma 2. Every cell on the (r + s) x 2s board is reachable from some 
cell in file 0. That is, for all (x, y) there is a z such that (x, y) is connected 
to (z, 0). 

Let us say that file y is accessible if its cells are all reachable from file 0. 
Let d — s — r. To prove that all files are accessible, we will start at file 0 
and, whenever file y is accessible, we will increase y by d if y < r, or 
decrease y by r if y > r. This procedure will prove accessibility for all 
y < s. It will then be obvious that all files y > s are accessible. 

If r < V < s and file y is accessible, we can easily show that file 
t — y — r is accessible by using Lemma 1. For if (x, t) is any cell in file t, 
there is a path from (x,t) to either (0, t) or (l,t), and we can go in one 


Ill 


544 Selected Papers on Fun and Games 

step from (z, t) to (2 + s, y) whenever z < r. If r = z — 1, we need three 
steps: ( 1 , 2 / - 1), (0,y + s- 1), (s,y + s), (s - 1 ,y). 

The other case is slightly more complicated. Suppose file y is acces- 
sible and 0 < y < r. Let (x, y + d) be any cell in file y + d. If x < r, 
we can go via (x + s, y + d + r) to (x + d, y) in two steps, and a similar 
two-step path goes from (x,y + d) to (x - d, y) if x > s. So the only 
problematic situation arises when r < x < s. In such a case we can 
follow a zigzag path 

(x, y + d), {x - r, y + d + s), (x + d, y + 2d), ..., ( x + kd,y + (k+l)d) 

until first reaching y + (k+l)d > r. When this occurs, we have kd < 
y + kd < r , so x + kd < s + kd < r + s is a legitimate rank. Now we 
can use Lemma 1 with r + t = y + (k+l)d to connect (x + kd, r + t) to 
either (0, r + t) or (1, r + t). And we can take another zigzag path from 
(0, r + t) back to file y as desired: 

(0,2/ + (k+l)d), ( s,y + (k+l)d + r), (d,y + kd), ..., 

(kd + s,y + d + r), ((fc+l)d, y) . 

Adding (1,0) to each point of this path will also connect (l, y + (k+l)d) 
to file y, unless kd = r — 1. 

Therefore our proof of Lemma 2 hinges on being able to find a path 
in the exceptional case kd = r — 1. This case can arise only when 
V = 0. Hence we must find a path from (x, s - 1) to file 0, for some odd 
integer x, whenever the parameters r and s satisfy the special conditions 
r = 1 + kd, s = 1 + (k+l)d. (Such leaper graphs exist whenever k > 0 
and d is odd.) An examination of small cases reveals a strategy that 
works in general: The path begins 

(d,s- 1), (s,2s-l) , 

(0, s — 1 + d), (s, 2d— 1), (d, s — 1 + 2d), ..., 

(kd, s IT (A:+l)d) = (2 — s, 2s — 2) , 

( 2 , s — 2 + d), (2 — s, 2d — 2), (z — d,s — 2 + 2d), ..., 

(2 kd, s — 2 + (fc+l)d) = (s, 2 s — 3) , 

and so on, where 2 = r + s- lis the number of the last rank; the idea is 
to repeat the (2k + l)-step staircase subpaths d - 1 times, until reaching 
(s, 2s — d). Since 2 s — d = r + s, point (s, 2s — d) is two easy steps from 
file 0; the proof of Lemma 2 is complete. □ 

Lemmas 1 and 2 together show that the graph has at most two 
connected components, because each vertex is connected either to cell 


Leaper Graphs 545 

(0,0) or cell (1,0) of file 0. Furthermore, the construction in the proof 
of Lemma 2 shows that (x,y) is connected to (0,0) if x + f(y) is even 
and to (1,0) if x + f(y) is odd, where f(y) is a certain parity function 
associated with hie y. This follows because the proof connects (x,y) to 
a cell congruent modulo 2 to (x + d, y + d) when we increase y by d, to 
(x + s, y — r) when we decrease y by r, and to (x + r,y + s) when we 
increase y by s. Thus we may take f(y+d) = f(y)+d, f(y—r ) = f(y)+s, 
and f(y + s) = f(y) + r. 

But the full cycle of changes in y involves exactly r increases by d, 
and exactly d decreases by r ; so we get back to y = 0 with a parity value 
of rd + sd , which is odd. Therefore (0,0) is connected to (1,0)! The 
proof of Theorem 1 is complete. □ 

The next natural question to ask about leaper graphs is whether 
or not they are Hamiltonian. Indeed, this is an especially appropriate 
question, because the whole idea of Hamiltonian cycles first arose in 
connection with knight’s tours which are Hamiltonian paths of the 
{l,2}-leaper graph on an 8 x 8 board. Knight’s tours have fascinated 
people for more than 1000 years, yet their secrets have not yet been fully 
unlocked. 

Dawson [2] showed that {1, 2fc}-leapers have Hamiltonian paths from 
corner to corner of a (2k + 1) x 4 k board. Therefore the smallest con- 
nected graph already has a Hamiltonian path when r = 1. However, 
Hamiltonian cycles are more difficult; they require larger boards, of size 
3 x 10 or 5 x 6 when k = 1, or 9 x 10 when k = 2. 

Jelliss [10] derived necessary conditions for the existence of Hamil- 
tonian cycles using {r, r + l}-leapers, and conjectured that the board of 
smallest area in this special case has size (2r + 1) x (6r + 4). He proved 
his conjecture when r < 3. The following theorem gives further support 
to Jelliss’s conjecture, because it shows that a board with smallest di- 
mension greater than 2r + 1 must have an area at least (4r + 2) 2 , which 
exceeds (2r + l)(6r + 4). 

Theorem 2. If r > 2 and the graph of an {r, r + 1}-Ieaper on an m, x n 
board has a Hamiltonian cycle, and if 2r + 1 < m < n, then m > 4r + 2. 

Proof. Let s = r + 1. All vertices (x, y) with 0 < x,y < r are adjacent 
only to (x + r, y + s) and (x + s, y + r). Therefore a Hamiltonian cycle 
must include both of these edges. Similarly, the edges from (x,y) to 
(x — r,y + s) and (x — s,y + r) are forced when m — r < x < m and 
0 < y < r. 

Therefore, if 2r+l < m < 3r+l, a “snag” [10] occurs at vertex (r, s): 
Any Hamiltonian cycle must lead from this vertex directly to (0,0), but 


546 Selected Papers on Fun and Games 

also to (2 r, 0) and (r + s, 1), because m — r<2r<r + s = 2r + l<m. 
Only two of these three compulsory moves are possible. 

Similarly, if 3r + 1 < m < 4r + 1, there is a snag at (2 r,s). This 
vertex must connect to (r - 1, 1), (3r, 0), and (3r + 1, 1). 

The case to = 3r + 1 is impossible if r > 1, because vertex (2 r - 1, s) 
must connect to (r - 2, 1), (3r - 1, 0), and (3 r, 1). 

Suppose finally that m = 4r + 1. Vertex (r - 1,2) has just two 
neighbors, (2 r - 1 ,r + 3) and (2 r,r + 2), because r > 2. Similarly, 
(3r + 1, 2) is adjacent only to (2r + 1, r + 3) and (2 r, r + 2). Therefore 
(2 r,r + 2) must not connect to (3r, 1). But now (3r, 1) has only two 
remaining options, namely (4r, r + 2) and (2r - 1, r + 1). This makes a 
snag at (2r — 1, r + 1), which must also link to (r- 1, 0) and (r-2, 1). □ 

On the other hand, Jelliss’s conjecture does turn out to be false for 
all r > 3, because { r,r + l}-leapers continue to acquire new problems 
on narrow boards as r grows: 

Theorem 3. If the graph of an {r, r + lj-leaper on a(2r+l)xn board 
has a Hamiltonian cycle, where r > 3, then n > r 2 + 5r + 2 if r is odd, 
n > r 2 + 6r + 4 if r is even. 

Proof. Let s = r + 1, and suppose first that we have a board of size 
(2r + 1) x oo. Certain edges are forced to be present in any Hamiltonian 
cycle, because some vertices have degree 2. We will see that such edges, 
in turn, can force other connections. 

Each vertex (a :,y) has at most four neighbors. If the x coordinate 
represents vertical position (rank) and the y coordinate represents hori- 
zontal position (file) as in matrix notation, two of these neighbors lie to 
the “left,” namely (x ± r, y - s) and (x ± s, y - r), and two lie to the 
“right,” (x±r,y + s) and (x ± s, y + r). (If x ^ r, there is one choice 
of sign for x ± s and x ± r; if x = r, neither choice works for x ± s, but 
both choices are valid for x ±r.) 

It will be convenient to use a two-dimensional representation of the 
files: The notation [a, 6] will refer to as — b, for a > 1 and 1 < b < s. In 
terms of this notation, the neighbors of all vertices in file [a, ft] belong 
to files [a — 1, b], [a — 1, b — 1], [a + 1, 6], and [a + 1, b + 1], (Appropriate 
adjustments to these formulas are made when a = 1 or b = 1 or b = s.) 

The files are also classified into various types: 

Type R: All vertices must link to both right neighbors. (For example, 
file [1, s] = 0 is type R because its vertices have no left neighbors. 
In fact, file [1, b } is type R for 2 < b < s.) 


Leaper Graphs 547 


Type R The middle vertex, in rank r, must link to both right neighbors. 
(File [1,1] is type R ! , because vertex (r, r) has no left neighbors; 
the other vertices in this file have one neighbor to the left.) 

Type L: All vertices must link to both left neighbors. (File [2, s] is 
type L, because both left neighbors of its vertices are in files of 
type R. In fact, file [2,6] is type L for 3 < 6 < s.) 

Type L': The middle vertex must link to both left neighbors. (File [2, 2] 
is type L ' .) 

Type i. All vertices except the middle must link to at least one left 
neighbor. (File [1,1] is type l , because for example vertex (0 , r) 
has a left neighbor in file 0, which is type R.) 

Type V: The extreme vertices, in ranks 0 and 2 r, must link to at least 
one left neighbor. (File [2, 1] = 2s — 1 is type l', because (0, 2s — 1) 
and (2r, 2s — 1) are the only neighbors of (r, r).) 

Additional types r and r' also arise when n is finite, because the right 
boundary has properties like that of the left. 

When file [a, 6] is type R, its right neighbors [a + 1,6] and [a + 1,6+1] 
must be either type L or l. When [a, 6] is type R' , [a + 1,6] is either L 
or V . And when files [a, 6] and [a, 6-1] both have type L, file [ a + 1, 6] 
must have type R\ its left neighbors cannot be used. Such arguments 
inductively establish the following facts for all a < s: 

[a, 6] is type R when a is odd, type L when a is even, for a < b < s; 

[a, a] is type R' when a is odd, type L' when a is even; 

[a, 1] is type l when a is odd and a < s; 

[a, a] is type l when a is even; 

[a, a — 1] is type l' when a is even. 

Furthermore [s + 1, s] is type l' when r is even. A file can simultaneously 
have two non-conflicting types; for example, [1, 1] is both R' and l, while 
[2,2] is both L' and l. At the other extreme, files with no forced links 
have no special type. 

To prove the theorem, we will show first that all files having special 
types when n = oo must be present when n is finite. Theorem 1 tells us 
that n > 2s; we want to prove that n > s 2 . Suppose n — ks — d, where 
0 < d < s and k < s. This right boundary introduces complementary 
constraints; let 


[a, 6] = n — 1 — [a, 6] = [k — a, d + 1 — 6] 


548 Selected Papers on Fun and Games 

be the file that corresponds to [a, b] when left and right are interchanged. 
Then file [a, b] has the type we have derived for [a, b ] but with the inter- 
change of L and P, l and r. The value of n = ks — d must be chosen so 
that complementary types do not conflict. 

First, k must be even. For if k is odd, file {k — l)s = [, k , s] is type R 
or P'; but it is also file [1, d + 1], which is type L or L' . 

Second, d must be even. For the {r, r + l}-leaper graphs are always 
bipartite — each leap links a “black” square with a “red” square, as on a 
chessboard — and a bipartite graph cannot be Hamiltonian when it has 
an odd number of vertices. 

Third, d cann ot be zero. Otherwise file [k,s] is type L or l, while 
it also is file [1, 1], which is typ e r. Since L is incompatible with r, we 
must have k = s. But then file [r, 1] is type r, conflicting with the fact 
that [r, 1] = [2, s] also is type L. 

Fourth, we must have k > d. Otherwise file [k — l,k — 1], which is 
type P', would link to the nonexistent file [k, k — 1] = n + d— 1 — k > n. 

Fifth, a contradiction arises even when the previous conditions are 
satisfied, so that k and d are even and 0 < d < k < s. Suppose, for 
example, that k— 10 and d = 6. All neighbors of vertices in Hamiltonian 
cycles are then forced except for certain vertices in 24 files: 


[1,1] 

[2,2] 

[3,3] 

— [4,4] 

[5,5] 

[6,6] 

[2,1] 

[3,2] 

[4,3] 

[5,4] 

[6,5] 

[7,6] 

[3,1] 

[4,2] 

[5,3] 

[6,4] 

[7,5] 

[8,6] 

M] 

[5,2] 

[6,3] 

[7,4] 

[8,5] 

[9,6] 


This follo ws because all files [a, b] with a < b are type P or L; and all 
files [a, b] with a < b are type L or P. We have [a, b] = [10 - a, 7 - 6], so 
the files in the array can also be represented in the dual form 


[9,6] — [8,5] — [7,4] — [6,3] — [5,2] — [4,1] 


[8,6] — [7,5] — [6,4] — [5,3] — [4,2] — [3,1] 


[7,6] 


[6,5] 


[5,4] 


[4,3] 


[3,2] 


[ 2 , 1 ] 


[ 2 , 2 ] — [ 1 . 1 ] 


[ 6 , 6 ] 


[5,5] 


[4,4] 


[3,3] 


Leaper Graphs 549 

All links between files are indicated by horizontal and vertical lines in 
these arrays. 

Let us say that a vertex is even or odd according as it belongs to file 
[a, b] where a is even or odd. All links go between even vertices and odd 
vertices. The edges of a Hamiltonian cycle that have not been forced 
by our arguments so far must therefore touch the same number of even 
vertices as odd vertices. We will obtain a contradiction by showing that 
the odd vertices have more unspecified neighbors in the Hamiltonian 
cycle than the even vertices do. 

In our example, the 24 files are classified as follows: 

R'l — L'l — R' — L'l — R' 

I I I I I 

V — 0 — V — 0 — V 

I I I I I 

l — r' — 0 — r' — 0 

I I I I I 

R'r — L' — R'r — L' — R'r 

An unconstrained file (indicated here by 0) has 2 r + 1 vertices with a 
total of 4r + 2 unspecified neighbors. Making it type l or r specifies 2r 
of these; making it type l', r' , L', or R' specifies 2. The total number of 
specified neighbors in odd files is 4(2r) + 6(2); the total in even files is 
6(2r) + 12(2). Therefore the odd vertices have an excess of unspecified 
neighbors; there aren’t enough “slots” available to specify them all. 

For general k and d, there are ( k — d)d files with partially unspecified 
vertices. There will be d/2 odd files of type R' , and d/2 of type L'; the 
same holds for even files. There are (k — d)/2 odd files of type l , and 
( k — d)/2 of type r; there are d/2 even files of type Z, and d/2 of type r. 
There are no odd files of types V or r'; there are d/2 even files of each of 
those types. Therefore the total number of unspecified vertices in even 
files will balance the total in odd files if and only if 

(k — d)(2r) = d(2r + 2) . 

The smallest solution to this equation, when d > 0 and k — d > 0, is 
k — d — r + 1, d = r. But then k — 2r + 1 exceeds s. 

We know therefore that n > s 2 . Hence all the files of special types, 
from [l,s] = 0 to [s + l,s] = s 2 , are present. Further considerations 
depend on whether r is even or odd. 

Suppose r is even. Then the arguments above can be used also in 
the case k = s + 1, except that when d=0we find that file [r, s] = [3, 1] 



550 Selected Papers on Fun and Games 

must be type r as well as type L. Contradictions are obtained exactly 
as before; lienee n > (s + l)s. 

We cannot have n = (s + 2)s - d for d 6 {3, 5, . . . , r - 1}, because 
file [s, .s], which is type L' , would be the same as file [3, d + 1], w hich is 
type R. The case d = 1 is also impossible, because file [s + 1, s], which 
has type r', is file [2,2], which has type L'l ; then vertices (0, 2r) and 
(2r,2r) would both link to (r,r - 1) and (3r,r + 1), forming a “short 
circuit.” Therefore n > (s + 2 )s. 

We can show that n > (s + 3)s by letting n = (s + 3)s — d and using 
the parity argument above with k = s + 3. When d = 2 the number of 
odd files of type l (and of type r) will be one less than before, because 
[s, 1] is not type Z, but this just makes the lack of balance even worse. 
Furthermore, when d = 0 and r > 4, Hie [r - 1, 1] = [6, s] has conflicting 
types r and L. 

When r = 4 and n = 40 = (s + 3)s, file [s + l,s] = [3, 1] has types r' 
and l. This forces file [2, 1] to be type L ' , and a loop of length 4r + 2 is 
forced from (r, 2 r + 1) to (2 r, r) to • ■ • to (0, r) to (r, 2 r + 1). 

And when n= (s+4)s-d for d {5, 7, . . . ,r-l}, filers] = [5,d+l] 

has conf licting types L' and R. In the remaining case d = 3, file 
[s + 1,.*] = [4,4] is r' and Z, forcing a loop from (r,3r - 1) to (0,4r) 
to (r, 5r + 1) to (2 r, 4 r) to (r, 3r - 1). 

Finally, suppose r is odd. We cannot have n = (s + l)s - d for 
d G {2, 4, . . . , r — 1} because file [s, s] = [2, d+ 1] has conflicting types R'r 
and L. The case d = 0 is also impossible, because file [s, s — 1] = [2,2] 
would be of types r' and L'l , forcing a short circuit as before. Next, if 
71 = ( s + 2)s — d , we us e the parity argument with k = s + 2 when d > 0. 
If d = 0 and r > 3, file [r, 1] = [4, s] has conflicting types r and L. And if 
we try to let n = (s + 3)s -d for d e {4,6, ... ,r- 1}, file [sTsJ = [4,cZ+l] 
has conflicting types R'r and L. □ 

Theorems 2 and 3 have proved that certain leaper graphs fail to be 
Hamiltonian. Let us now strike a happier note by constructing infinitely 
many Hamiltonian cycles, on the boards that have the smallest area not 
ruled out by those theorems. 

Theorem 4. The graph of an {r, r + l}-leaper on a (4r + 2) X (4r + 2) 
board is Hamiltonian. 

Proof. Let us call the leaper moves ne, nw, en, es, se, sw, ws, and wn, 
where (n, e, S, w) stand respectively for North, East, South, West, and 
where the first letter indicates the direction of longest leap. North is the 
direction of decreasing x\ East is the direction of increasing y. Thus NE 
is a leap from (x,y) to (x - r - 1, y + r); ES goes to (x + r, y + r + 1). 


Leaper Graphs 551 


We construct first a highly symmetric set of leaper moves in which 
every vertex has degree 2, illustrated here in the case r = 4 and s — 5: 


SE 

SE 

SE 

SE 

Dx 

SW 

SW 

SW 

a 4 

a 4 

SE 

SE 

SE 

D r 

SW 

SW 

sw 

SW 

ES 

ES 

ES 

ES 

WS 

ws 

WS 

ES 

ES 

ES 

ws 

WS 

WS 

WS 

SE 

SE 

SE 

SE 

d 2 

sw 

sw 

SW 

A 3 

^3 

SE 

SE 

SE 

d 2 

sw 

SW 

SW 

SW 

ES 

ES 

ES 

ES 

ws 

ws 

ws 

ES 

ES 

ES 

ws 

WS 

ws 

WS 

SE 

SE 

SE 

SE 

d 3 

sw 

sw 

sw 


~A , 

SE 

SE 

SE 

Ds 

sw 

sw 

sw 

SW 

ES 

ES 

ES 

ES 

ws 

ws 

ws 

s±2 

s±2 

ES 

ES 

ES 

ws 

ws 

ws 

ws 

SE 

SE 

SE 

SE 

D a 

sw 

sw 

sw 

Tli 

Ax 

SE 

SE 

SE 

Da 

sw 

sw 

sw 

sw 

ES 

ES 

ES 

ES 

ws 

ws 

ws 

ES 

ES 

ES 

ws 

ws 

ws 

ws 

B 1 

Bo 

B 3 

b 4 

Fa 

Fa 

e 3 

e 2 

Fa 

Ex 

e 2 

Es 

E 4 

Fa 

Ba 

Bs 

Bo 

Bx 

NE 

NE 

NE 

NE 

f 3 

NW 

NW 

NW 

NW 

NE 

NE 

NE 

NE 

Fs 

NW 

NW 

NW 

NW 

EN 

EN 

EN 

EN 

WN 

WN 

WN 

WN 

EN 

EN 

EN 

EN 

WN 

WN 

WN 

WN 

NE 

NE 

NE 

NE 

f 2 

NW 

NW 

NW 

NW 

NE 

NE 

NE 

NE 


NW 

NW 

NW 

NW 

EN 

EN 

EN 

EN 

WN 

WN 

WN 

WN 

EN 

EN 

EN 

EN 

r 2 

WN 

WN 

WN 

WN 

NE 

NE 

NE 

NE 

Fa 

NW 

NW 

NW 

NW 

NE 

NE 

NE 

NE 


NW 

NW 

NW 

NW 

EN 

EN 

EN 

EN 

WN 

WN 

WN 

WN 

EN 

EN 

EN 

EN 

r 1 

WN 

WN 

WN 

WN 

X 

NE 

EN 

NE 

EN 

NE 

EN 

C 0 

Cr 

c 2 

c 3 

C 4 

C 4 

Cs 

c 2 

Cx 

Co 

NW 

WN 

NW 

WN 

NW 

WN 

X 

X' 

SE 

ES 

SE 

ES 

SE 

ES 

C'o 

C[ 


c!a 

C'a 

C'a 

C's 

c 2 

C\ 

Co 

SW 

ws 

SW 

WS 

SW 

WS 

x' 

SE 

SE 

SE 

SE 

F[ 

SW 

SW 

sw 

SW 

SE 

SE 

SE 

SE 

F'a 

sw 

sw 

SW 

SW 

ES 

ES 

ES 

ES 

ws 

ws 

ws 

ws 

ES 

ES 

ES 

ES 

ws 

ws 

WS 

ws 

SE 

SE 

SE 

SE 

F2 

sw 

sw 

sw 

sw 

SE 

SE 

SE 

SE 


sw 

sw 

SW 

sw 

ES 

ES 

ES 

ES 

ws 

ws 

ws 

ws 

ES 

ES 

ES 

ES 

r 2 

ws 

ws 

ws 

ws 

SE 

SE 

SE 

SE 

F 3 

sw 

sw 

sw 

sw 

SE 

SE 

SE 

SE 


sw 

sw 

sw 

sw 

ES 

ES 

ES 

ES 

ws 

ws 

ws 

ws 

ES 

ES 

ES 

ES 

r 3 

ws 

ws 

ws 

ws 

B[ 

b ' 2 

b ' 3 

B\ 

F'a 

F'a 

E's 

E' 2 

E[ 

% 

e ' 2 

% 

F'a 

F'a 

b'a 

B's 

b ' 2 

b'a 

NE 

NE 

NE 

NE 

D'a 

NW 

NW 

NW 

A' 

a' 

NE 

NE 

NE 

D'a 

NW 

NW 

NW 

NW 

EN 

EN 

EN 

EN 

WN 

WN 

WN 



EN 

EN 

EN 

WN 

WN 

WN 

WN 

NE 

NE 

NE 

NE 

D's 

NW 

NW 

NW 

A' 

a' 

NE 

NE 

NE 

D's 

NW 

NW 

NW 

NW 

EN 

EN 

EN 

EN 

WN 

WN 

WN 



EN 

EN 

EN 

WN 

WN 

WN 


NE 

NE 

NE 

NE 

d ' 2 

NW 

NW 

NW 

A' 


NE 

NE 

NE 

d ' 2 

NW 

NW 

NW 

NW 

EN 

EN 

EN 

EN 

WN 

WN 

WN 

.3 

EN 

EN 

EN 

WN 

WN 

WN 

WN 

NE 

NE 

NE 

NE 

D[ 

NW 

NW 

NW 

A' 

a'a 

NE 

NE 

NE 

D'a 

NW 

NW 

NW 

NW 

EN 

EN 

EN 

EN 

WN 

WN 

WN 


EN 

EN 

EN 

WN 

WN 

WN 

WN 


Some vertices have been given names Aj , Bj , etc.; these provide im- 
portant connecting links. The other, nameless vertices occur in blocks 
where all links have the same pair of directions; for example, every vertex 
called If is joined to its SE and ES neighbors. These blocks effectively 
serve as parallel mirrors that provide staircase paths, rising or falling 
at 45° angles, such as the implicit 7-step path from Ai to B j. 

The named vertices are connected as follows: 

Aj goes WS, ES; 

Bj goes SE, EN; 

Cj goes nw, sw, except C r goes nw, SE; 

Dj goes SE, SW; 

Ej goes wn, ws, except E r goes wn, SE; 

Fj goes NW, en, except F r goes SW, EN; 

X goes NE, SE. 


552 Selected Papers on Fun and Games 

The directions for complemented vertices like Aj are the same but with 
E and W interchanged; the directions for primed vertices like A' are 
the same but withN and s interchanged. Thus, for example, vertex B' 
goes NE, ES; and F r goes ne, ws. It is easy to verify that these pairs of 
directions are consistent: The endpoints of each edge point to each other. 

We can now deduce the connections between named vertices, follow- 
ing paths through unnamed ones. The nearest named neighbors of A } 
are Bj and Fj. The nearest to Bj are Aj and C'_ 1 . The nearest to Cj 
are Dj (or E\ when j — 0) and B' ]+1 (or E r when j = r). The nearest 
to Dj are Cj and Ej (or A when j = r). The nearest to Ej are Dj (or 
C r when j = r) and Fj _ i (or Co when j — 1). The nearest to Fj are 
Aj and E J+1 (or X' when j = r). And the nearest to X are D r and F' r . 

Each chain of edges therefore falls into a pattern that depends on 
the value of r mod 4. If r = 4 k we have 


X . 

• D r .. C r . . E r 

• ■ F r _ 

i 




1 

cq 

i 

^ f- 

C r -2 

■ • D r _2 ■ ■ 

E , — 2 

. . F r _ 3 


• A r —3 . . 5 r _3 . . 

C'r - 4 

■ . D' r _ 4 . . 

E r -4 

f' 

’ ‘ r r — 5 


. E 2 . . Fi . . Ax 

,.B X . 

■Co ■■ X 

.. d\ 

. . C x . . £?2 • • A 2 ■ ■ ■ 


■ A r — 2 • • F r — 2 • • 

E r - i 

■ ■ D r _ i . . 

C r -l ■ 

. B' r . . A' r . . F' r . . X. 

If r 

= 4fc + 2 the pattern is 

almost the 

same 

except that the middle 


transition is complemented and primed: 

• • % . . F[ .. A[ . . B[ . . C 0 . . E\ .. D l .. (\ . . B ' 2 . . A ' 2 • • ■ . 

If r = 4k + 1 the pattern in the middle is 

• • E 3 . . F 2 . . A 2 . . B 2 . . c[ . . d[ . . e\ . . Co . . B 1 . . At ■ ■ - 

ending with A r .. F r . . X' . And if r = 4fc + 3, the middle is again 
complemented and primed; again the path ends with A r . . F r . . X' . 

Conseque